Commit 3e9f7344 authored by Ad Schellevis's avatar Ad Schellevis

(filter) add maximum size option to parsePlain

parent 7bc5bf4d
......@@ -53,7 +53,7 @@ class FilterRule
'to_port' => 'parsePlain, port {,}',
'icmp6-type' => 'parsePlain,icmp6-type {,}',
'state' => 'parseState',
'label' => 'parsePlain,label ","'
'label' => 'parsePlain,label ",",63'
);
/**
......@@ -69,10 +69,16 @@ class FilterRule
/**
* parse plain data
* @param string $value field value
* @param string $prefix prefix when $value is provided
* @param string $suffix suffix when $value is provided
* @param int $maxsize maximum size, cut when longer
* @return string
*/
private function parsePlain($value, $prefix="", $suffix="")
private function parsePlain($value, $prefix="", $suffix="", $maxsize=null)
{
if (!empty($maxsize) && strlen($value) > $maxsize) {
$value = substr($value, 0, $maxsize);
}
return $value == '' ? "" : $prefix . $value . $suffix . " ";
}
......
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