Skip to content

Commit 9b89182

Browse files
committed
Improved input checks in the DNS wizard. Related to: FS#939 - DNS Bug
1 parent 74829e1 commit 9b89182

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

interface/web/dns/dns_wizard.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@
137137
if(isset($_POST['ns2']) && $_POST['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />';
138138
if(isset($_POST['email']) && $_POST['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
139139

140+
if(!preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z]{2,10}[\.]{0,1}$/',$_POST['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
141+
if(!preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z]{2,10}[\.]{0,1}$/',$_POST['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
142+
if(!preg_match('/^[\w\.\-]{2,64}\.[a-zA-Z]{2,10}[\.]{0,1}$/',$_POST['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
143+
if(!preg_match('/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,10}$/i',$_POST['email'])) $error .= $app->lng('error_email_regex').'<br />';
144+
140145
// make sure that the record belongs to the clinet group and not the admin group when a dmin inserts it
141146
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($_POST['client_group_id'])) {
142147
$sys_groupid = intval($_POST['client_group_id']);

interface/web/dns/lib/lang/en_dns_wizard.lng

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ $wb['error_ip_empty'] = 'IP empty.';
2323
$wb['error_ns1_empty'] = 'NS1 empty.';
2424
$wb['error_ns2_empty'] = 'NS2 empty.';
2525
$wb['error_email_empty'] = 'EMail empty.';
26-
26+
$wb['error_domain_regex'] = 'Domain contains invalid characters.';
27+
$wb['error_ns1_regex'] = 'NS1 contains invalid characters.';
28+
$wb['error_ns2_regex'] = 'NS2 contains invalid characters.';
29+
$wb['error_email_regex'] = 'Email does not contain a valid email address.';
2730
?>

0 commit comments

Comments
 (0)