mirror of https://github.com/MISP/MISP
chg: [internal] Simplified link and boolean validation
parent
2f99629679
commit
a1d21ecb73
|
@ -184,10 +184,10 @@ class AttributeValidationTool
|
|||
$value = strtolower($value);
|
||||
return str_replace(':', '|', $value);
|
||||
case 'boolean':
|
||||
if ('true' == trim(strtolower($value))) {
|
||||
$value = trim(strtolower($value));
|
||||
if ('true' === $value) {
|
||||
$value = 1;
|
||||
}
|
||||
if ('false' == trim(strtolower($value))) {
|
||||
} else if ('false' === $value) {
|
||||
$value = 0;
|
||||
}
|
||||
return $value ? '1' : '0';
|
||||
|
@ -457,7 +457,7 @@ class AttributeValidationTool
|
|||
return true;
|
||||
case 'link':
|
||||
// Moved to a native function whilst still enforcing the scheme as a requirement
|
||||
return filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED) && !preg_match("#\n#", $value);
|
||||
return (bool)filter_var($value, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED);
|
||||
case 'hex':
|
||||
return ctype_xdigit($value);
|
||||
case 'target-user':
|
||||
|
@ -571,7 +571,7 @@ class AttributeValidationTool
|
|||
if (self::isPositiveInteger($value) && $value <= 4294967295) {
|
||||
return true;
|
||||
}
|
||||
return __('AS number have to be integers between 1 and 4294967295');
|
||||
return __('AS number have to be integer between 1 and 4294967295');
|
||||
}
|
||||
throw new InvalidArgumentException("Unknown type $type.");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue