Commit 6ed08cf6 authored by Jesse Norell's avatar Jesse Norell
Browse files

allow 1-char domain names

parent c4417ba5
Pipeline #9224 passed with stage
in 9 minutes and 54 seconds
......@@ -248,7 +248,7 @@ class remoting_dns extends remoting {
return false;
}
if(!preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,63}$/', $origin)){
if(!preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9\-]{2,63}$/', $origin)){
throw new SoapFault('no_domain_found', 'Invalid domain name.');
return false;
}
......
......@@ -131,7 +131,7 @@ $form["tabs"]['server'] = array(
'validators' => array( 0 => array('type' => 'NOTEMPTY',
'errmsg' => 'hostname_error_empty'),
1 => array ('type' => 'REGEX',
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/',
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
'errmsg'=> 'hostname_error_regex'),
),
'value' => '',
......
......@@ -100,7 +100,7 @@ $form["tabs"]['domain'] = array (
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'domain_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/',
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
'errmsg'=> 'domain_error_regex'),
),
'default' => '',
......
......@@ -276,18 +276,20 @@ if($_POST['create'] == 1) {
}
# fixme: this regex is pretty poor for domain validation
if(isset($_POST['domain']) && $_POST['domain'] == '') $error .= $app->lng('error_domain_empty').'<br />';
elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,63}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
elseif(isset($_POST['domain']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9\-]{2,63}$/', $_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
if(isset($_POST['ip']) && $_POST['ip'] == '') $error .= $app->lng('error_ip_empty').'<br />';
if(isset($_POST['ipv6']) && $_POST['ipv6'] == '') $error .= $app->lng('error_ipv6_empty').'<br />';
# fixme: this regex is pretty poor for hostname validation
if(isset($_POST['ns1']) && $_POST['ns1'] == '') $error .= $app->lng('error_ns1_empty').'<br />';
elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
elseif(isset($_POST['ns1']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />';
elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
elseif(isset($_POST['ns2']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
elseif(isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) $error .= $app->lng('error_email_regex').'<br />';
......@@ -326,7 +328,7 @@ if($_POST['create'] == 1) {
// $enable_dnssec = (($_POST['dnssec'] == 'Y') ? 'Y' : 'N');
// if(isset($_POST['dnssec'])) $vars['dnssec_wanted'] = 'Y';
if(isset($_POST['dnssec'])) $tpl_content = str_replace('[ZONE]', '[ZONE]'."\n".'dnssec_wanted=Y', $tpl_content);
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/', $_POST['domain'])) {
if(isset($_POST['dkim']) && preg_match('/^[\w\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/', $_POST['domain'])) {
$sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $_POST['domain']);
$public_key = $sql['dkim_public'];
if ($public_key!='') {
......
......@@ -96,7 +96,7 @@ $form["tabs"]['dns_slave'] = array (
'errmsg'=> 'origin_error_unique'),
*/
1 => array ( 'type' => 'REGEX',
'regex' => '/^[a-zA-Z0-9\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
'regex' => '/^[a-zA-Z0-9\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
'errmsg'=> 'origin_error_regex'),
),
'default' => '',
......
......@@ -120,7 +120,7 @@ $form["tabs"]['dns_soa'] = array (
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'origin_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^[a-zA-Z0-9\.\-\/]{2,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
'regex' => '/^[a-zA-Z0-9\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/',
'errmsg'=> 'origin_error_regex'),
),
'default' => '',
......
......@@ -113,7 +113,7 @@ header('Content-type: application/json');
echo $json;
function validate_domain($domain) {
$regex = '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/';
$regex = '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/';
if ( preg_match($regex, $domain) === 1 ) return true; else return false;
}
......
......@@ -86,7 +86,7 @@ $form["tabs"]['alias'] = array (
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'source_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^\@[\w\.\-]{2,64}\.[a-zA-Z0-9\-]{2,20}$/',
'regex' => '/^\@[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
'errmsg'=> 'source_error_regex'),
),
'default' => '',
......
......@@ -86,7 +86,7 @@ $form["tabs"]['catchall'] = array (
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'domain_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^\@[\w\.\-]{2,255}\.[a-zA-Z\-]{2,63}$/',
'regex' => '/^\@[\w\.\-]{1,255}\.[a-zA-Z\-]{2,63}$/',
'errmsg'=> 'domain_error_regex'),
),
'default' => '',
......
......@@ -87,7 +87,7 @@ $form["tabs"]['mailinglist'] = array (
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'domain_error_empty'),
1 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z\-]{2,10}$/',
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z\-]{2,10}$/',
'errmsg'=> 'domain_error_regex'),
),
'default' => '',
......
......@@ -103,7 +103,7 @@ $form["tabs"]['domain'] = array (
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'domain_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,63}$/',
'regex' => '/^[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,63}$/',
'errmsg'=> 'domain_error_regex'),
),
'default' => '',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment