fix: Relaxed TLD validation for hostname|port, domain|ip, jabber-id, fixes #1977

pull/1994/head
Iglocska 2017-02-26 08:54:11 +01:00
parent 100bb371e7
commit 6f8db935a6
1 changed files with 3 additions and 3 deletions

View File

@ -797,14 +797,14 @@ class Attribute extends AppModel {
break;
case 'hostname|port':
$parts = explode('|', $value);
if (preg_match("#^[A-Z0-9.\-_]+\.[A-Z]{2,}$#i", $parts[0])) {
if (preg_match("#^[A-Z0-9.\-_]+\.[A-Z0-9\-]{2,}$#i", $parts[0])) {
if (!is_numeric($parts[1]) || $parts[1] > 1 || $parts[1] < 65536) {
$returnValue = true;
}
}
break;
case 'domain|ip':
if (preg_match("#^[A-Z0-9.\-_]+\.[A-Z]{2,}\|.*$#i", $value)) {
if (preg_match("#^[A-Z0-9.\-_]+\.[A-Z0-9\-]{2,}\|.*$#i", $value)) {
$parts = explode('|', $value);
if (filter_var($parts[1], FILTER_VALIDATE_IP)) {
$returnValue = true;
@ -822,7 +822,7 @@ class Attribute extends AppModel {
case 'dns-soa-email':
case 'jabber-id':
// we don't use the native function to prevent issues with partial email addresses
if (preg_match("#^[A-Z0-9._&%+-=~]*@[A-Z0-9.\-_]+\.[A-Z]{2,}$#i", $value)) {
if (preg_match("#^[A-Z0-9._&%+-=~]*@[A-Z0-9.\-_]+\.[A-Z0-9\-]{2,}$#i", $value)) {
$returnValue = true;
} else {
$returnValue = 'Email address has an invalid format. Please double check the value or select type "other".';