From 08853db4fa8d14dca94d4b932fe685b57ece7a81 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 17 Dec 2021 10:44:47 +0100 Subject: [eventlog] Change template referencing syntax If no "capture group" is given, assume group 1, which is (virtually) the only group that exists for any filter except regex. Change the separator from . to :, to disambiguate from the optionaly unit specifier. So for most cases, you just have %1%, %2mb% etc. --- modules-available/eventlog/inc/filterruleprocessor.inc.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules-available/eventlog/inc/filterruleprocessor.inc.php b/modules-available/eventlog/inc/filterruleprocessor.inc.php index 897f923d..efb79a66 100644 --- a/modules-available/eventlog/inc/filterruleprocessor.inc.php +++ b/modules-available/eventlog/inc/filterruleprocessor.inc.php @@ -285,9 +285,12 @@ class FilterRuleProcessor private static function fillTemplate(string $template, array $values): string { - return preg_replace_callback('/%([0-9]+)\.([0-9]+|[a-z][a-z0-9]*)\.?([a-z]*)%/', function($m) use ($values) { + return preg_replace_callback('/%([0-9]+)(?::([0-9]+|[a-z][a-z0-9]*))?\.?([a-z]*)%/', function($m) use ($values) { if (!isset($values[$m[1]])) return ''; + if (($m[2] ?? '') === '') { + $m[2] = 1; + } if (!isset($values[$m[1]][$m[2]])) return ''; $v = $values[$m[1]][$m[2]]; @@ -326,4 +329,4 @@ class FilterRuleProcessor return $a; } -} \ No newline at end of file +} -- cgit v1.2.3-55-g7522