Skip to content

Commit

Permalink
respect possible empty-value when validating string::validate_ip
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
  • Loading branch information
d00p committed Feb 12, 2015
1 parent df3b97c commit 37ca789
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -107,8 +107,14 @@ function validateFormFieldString($fieldname, $fielddata, $newfieldvalue)
}
}
elseif (isset($fielddata['string_type']) && $fielddata['string_type'] == 'validate_ip') {
$newfieldvalue = validate_ip2($newfieldvalue);
$returnvalue = ($newfieldvalue !== false ? true : 'invalidip');
// check for empty value (it might be allowed)
if (trim($newfieldvalue) == '') {
$newfieldvalue = '';
$returnvalue = 'stringmustntbeempty';
} else {
$newfieldvalue = validate_ip2($newfieldvalue, true);
$returnvalue = ($newfieldvalue !== false ? true : 'invalidip');
}
}
elseif (preg_match('/^[^\r\n\t\f\0]*$/D', $newfieldvalue)) {
$returnvalue = true;
Expand Down

0 comments on commit 37ca789

Please sign in to comment.