diff options
author | Phil Davis <phil.davis@inf.org> | 2017-02-22 20:53:19 +0545 |
---|---|---|
committer | Phil Davis <phil.davis@inf.org> | 2017-02-22 20:53:19 +0545 |
commit | 680e15baef76a9c598d52d3f2b9ab498077336a8 (patch) | |
tree | 5c099d11d76703e417600edae1b3d8b64905015e /src/etc | |
parent | aba748830d69b05df8c4a4cee370413c91c32273 (diff) | |
download | pfsense-680e15baef76a9c598d52d3f2b9ab498077336a8.zip pfsense-680e15baef76a9c598d52d3f2b9ab498077336a8.tar.gz |
Fix 7294 keep full rule description
Signed-off-by: Phil Davis <phil.davis@inf.org>
Diffstat (limited to 'src/etc')
-rw-r--r-- | src/etc/inc/filter.inc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index 6890c98..9cac2ed 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -102,6 +102,8 @@ $icmptypes = array( define("ANTILOCKOUT_TRACKER", 10000); define("BOGONS_TRACKER", 11000); define("RFC1918_TRACKER", 12000); +define("PFLABEL_MAXLEN", 63); +define("USER_LABEL_INTRO", "USER_RULE: "); $tracker = 1000000000; $negate_tracker = 10000000; @@ -119,10 +121,15 @@ function filter_negaterule_tracker() { return "tracker {$negate_tracker} "; } +function user_rule_descr_maxlen() { + return PFLABEL_MAXLEN - strlen(USER_LABEL_INTRO); +} + function fix_rule_label($descr) { $descr = str_replace('"', '', $descr); - if (strlen($descr) > 63) { - return substr($descr, 0, 60) . "..."; + if (strlen($descr) > PFLABEL_MAXLEN) { + $dots = "..."; + return substr($descr, 0, PFLABEL_MAXLEN - strlen($dots)) . $dots; } else { return $descr; } @@ -2374,7 +2381,7 @@ function filter_generate_user_rule_arr($rule) { $ret['rule'] = $line; $ret['interface'] = $rule['interface']; if ($rule['descr'] != "" and $line != "") { - $ret['descr'] = "label \"" . fix_rule_label("USER_RULE: {$rule['descr']}") . "\""; + $ret['descr'] = "label \"" . fix_rule_label(USER_LABEL_INTRO . "{$rule['descr']}") . "\""; } else { $ret['descr'] = "label \"USER_RULE\""; } |