Commit 4d92687a authored by Ad Schellevis's avatar Ad Schellevis

filter, rule generation. don't wrap aliases in curly brackets, it seems to...

filter, rule generation. don't wrap aliases in curly brackets, it seems to crash when a to port is written like {$portalias}
parent efd25658
......@@ -50,11 +50,11 @@ class FilterRule
'reply' => 'parsePlain',
'ipprotocol' => 'parsePlain',
'protocol' => 'parseReplaceSimple,tcp/udp:{tcp udp},proto ',
'from' => 'parsePlain,from {,}',
'from_port' => 'parsePlain, port {,}',
'from' => 'parsePlainCurly,from ',
'from_port' => 'parsePlainCurly, port ',
'os' => 'parsePlain, os {","}',
'to' => 'parsePlain,to {,}',
'to_port' => 'parsePlain, port {,}',
'to' => 'parsePlainCurly,to ',
'to_port' => 'parsePlainCurly, port ',
'icmp-type' => 'parsePlain,icmp-type {,}',
'icmp6-type' => 'parsePlain,icmp6-type {,}',
'flags' => 'parsePlain, flags ',
......@@ -93,6 +93,23 @@ class FilterRule
return $value == null || $value === '' ? '' : $prefix . $value . $suffix . ' ';
}
/**
* parse plain data
* @param string $value field value
* @param string $prefix prefix when $value is provided
* @return string
*/
private function parsePlainCurly($value, $prefix = "")
{
$suffix = "";
if (strpos($value, '$') === false) {
// don't wrap aliases in curly brackets
$prefix = $prefix . "{";
$suffix = "}";
}
return $value == null || $value === '' ? '' : $prefix . $value . $suffix . ' ';
}
/**
* parse data, use replace map
* @param string $value field value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment