Skip to content

Commit 6ed08cf

Browse files
committed
allow 1-char domain names
1 parent c4417ba commit 6ed08cf

File tree

11 files changed

+16
-14
lines changed

11 files changed

+16
-14
lines changed

interface/lib/classes/remote.d/dns.inc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function dns_zone_get_id($session_id, $origin) {
248248
return false;
249249
}
250250

251-
if(!preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,63}$/', $origin)){
251+
if(!preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9\-]{2,63}$/', $origin)){
252252
throw new SoapFault('no_domain_found', 'Invalid domain name.');
253253
return false;
254254
}

interface/web/admin/form/server_config.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
'validators' => array( 0 => array('type' => 'NOTEMPTY',
132132
'errmsg' => 'hostname_error_empty'),
133133
1 => array ('type' => 'REGEX',
134-
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/',
134+
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
135135
'errmsg'=> 'hostname_error_regex'),
136136
),
137137
'value' => '',

interface/web/client/form/domain.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
1 => array ( 'type' => 'UNIQUE',
101101
'errmsg'=> 'domain_error_unique'),
102102
2 => array ( 'type' => 'REGEX',
103-
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/',
103+
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
104104
'errmsg'=> 'domain_error_regex'),
105105
),
106106
'default' => '',

interface/web/dns/dns_wizard.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,20 @@
276276
}
277277

278278

279+
# fixme: this regex is pretty poor for domain validation
279280
if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty').'<br />';
280-
elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,63}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
281+
elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9\-]{2,63}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
281282

282283
if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty').'<br />';
283284

284285
if(isset($_POST['ipv6']) && $_POST['ipv6'] == '') $error .= $app->lng('error_ipv6_empty').'<br />';
285286

287+
# fixme: this regex is pretty poor for hostname validation
286288
if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty').'<br />';
287-
elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
289+
elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
288290

289291
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />';
290-
elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
292+
elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
291293

292294
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
293295
elseif(isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) $error .= $app->lng('error_email_regex').'<br />';
@@ -326,7 +328,7 @@
326328
// $enable_dnssec = (($_POST['dnssec'] == 'Y') ? 'Y' : 'N');
327329
// if(isset($_POST['dnssec'])) $vars['dnssec_wanted'] = 'Y';
328330
if(isset($_POST['dnssec'])) $tpl_content = str_replace('[ZONE]', '[ZONE]'."\n".'dnssec_wanted=Y', $tpl_content);
329-
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/', $_POST['domain'])) {
331+
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/', $_POST['domain'])) {
330332
$sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']);
331333
$public_key = $sql['dkim_public'];
332334
if ($public_key!='') {

interface/web/dns/form/dns_slave.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
'errmsg'=> 'origin_error_unique'),
9797
*/
9898
1 => array ( 'type' => 'REGEX',
99-
'regex' => '/^[a-zA-Z0-9\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
99+
'regex' => '/^[a-zA-Z0-9\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
100100
'errmsg'=> 'origin_error_regex'),
101101
),
102102
'default' => '',

interface/web/dns/form/dns_soa.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
1 => array ( 'type' => 'UNIQUE',
121121
'errmsg'=> 'origin_error_unique'),
122122
2 => array ( 'type' => 'REGEX',
123-
'regex' => '/^[a-zA-Z0-9\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
123+
'regex' => '/^[a-zA-Z0-9\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
124124
'errmsg'=> 'origin_error_regex'),
125125
),
126126
'default' => '',

interface/web/mail/ajax_get_json.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
echo $json;
114114

115115
function validate_domain($domain) {
116-
$regex = '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/';
116+
$regex = '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/';
117117
if ( preg_match($regex, $domain) === 1 ) return true; else return false;
118118
}
119119

interface/web/mail/form/mail_aliasdomain.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
1 => array ( 'type' => 'UNIQUE',
8787
'errmsg'=> 'source_error_unique'),
8888
2 => array ( 'type' => 'REGEX',
89-
'regex' => '/^\@[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,20}$/',
89+
'regex' => '/^\@[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
9090
'errmsg'=> 'source_error_regex'),
9191
),
9292
'default' => '',

interface/web/mail/form/mail_domain_catchall.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
1 => array ( 'type' => 'UNIQUE',
8787
'errmsg'=> 'domain_error_unique'),
8888
2 => array ( 'type' => 'REGEX',
89-
'regex' => '/^\@[\w\.\-]{2,255}\.[a-zA-Z\-]{2,63}$/',
89+
'regex' => '/^\@[\w\.\-]{1,255}\.[a-zA-Z\-]{2,63}$/',
9090
'errmsg'=> 'domain_error_regex'),
9191
),
9292
'default' => '',

interface/web/mail/form/mail_mailinglist.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
8888
'errmsg'=> 'domain_error_empty'),
8989
1 => array ( 'type' => 'REGEX',
90-
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z\-]{2,10}$/',
90+
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z\-]{2,10}$/',
9191
'errmsg'=> 'domain_error_regex'),
9292
),
9393
'default' => '',

0 commit comments

Comments
 (0)