mirror of
https://github.com/opnsense/core.git
synced 2026-10-12 02:20:36 +00:00
mvc: PortField: always return a string for normalizedPort()
This commit is contained in:
@@ -650,7 +650,7 @@ function filter_core_rules_system($fw, $defaults)
|
||||
'log' => $dnatrule['log'],
|
||||
'descr' => $dnatrule['descr']
|
||||
];
|
||||
$local_port = (string)$rule->{'local-port'}->normalizedPort();
|
||||
$local_port = $rule->{'local-port'}->normalizedPort();
|
||||
if (!empty($dnatrule['destination']['port']) && ctype_digit($local_port)) {
|
||||
$tmprule['destination']['port'] = $local_port;
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ class PortField extends BaseListField
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function normalizedPort()
|
||||
public function normalizedPort(): string
|
||||
{
|
||||
/* XXX this does not support multiple values */
|
||||
$value = $this->getValue();
|
||||
@@ -281,7 +281,7 @@ class PortField extends BaseListField
|
||||
|
||||
$known = self::getWellKnown($value);
|
||||
if (!empty($known)) {
|
||||
$value = array_shift($known);
|
||||
$value = (string)array_shift($known);
|
||||
}
|
||||
|
||||
return $value;
|
||||
|
||||
@@ -70,7 +70,7 @@ class SourceNatRuleContainerField extends ContainerField
|
||||
$result[$target_fieldname] = (string)$node;
|
||||
}
|
||||
} elseif ($key == 'target_port' && is_a($node, PortField::class) && $node->getValue() != '') {
|
||||
$result[$target_fieldname] = (string)$node->normalizedPort();
|
||||
$result[$target_fieldname] = $node->normalizedPort();
|
||||
} elseif ((string)$node != '') {
|
||||
/*
|
||||
* XXX: Omit empty values to allow array_merge() to overlay default values in Plugin.php.
|
||||
|
||||
Reference in New Issue
Block a user