Firewall/Alias, phalcon's Callback() validator sends all received data and expects the callback to filter them, which forces us to include the fieldname in the validator to prevent feeding the wrong results. for https://github.com/opnsense/core/issues/1858

This commit is contained in:
Ad Schellevis 2018-06-26 18:03:11 +02:00
parent 51bd00cf82
commit 19bbaeaa29
2 changed files with 8 additions and 4 deletions

View File

@ -80,8 +80,10 @@ class AliasContentField extends BaseField
private function getItems($data)
{
foreach ($data as $key => $value) {
foreach (explode($this->separatorchar, $value) as $value) {
yield $value;
if (substr( $key, strlen( $key ) - strlen( ".content" ) ) == ".content") {
foreach (explode($this->separatorchar, $value) as $value) {
yield $value;
}
}
}
}

View File

@ -77,9 +77,11 @@ class AliasNameField extends BaseField
"message" => gettext('Reserved protocol or service names may not be used'),
"callback" => function ($data) {
foreach ($data as $key => $value) {
if (getservbyname($value, 'tcp') ||
if (substr( $key, strlen( $key ) - strlen( ".name" ) ) == ".name") {
if (getservbyname($value, 'tcp') ||
getservbyname($value, 'udp') || getprotobyname($value)) {
return false;
return false;
}
}
}
return true;