diff options
author | Simon Rettberg | 2021-12-17 10:44:47 +0100 |
---|---|---|
committer | Simon Rettberg | 2021-12-17 10:44:47 +0100 |
commit | 08853db4fa8d14dca94d4b932fe685b57ece7a81 (patch) | |
tree | 67adf95a821b1902de1ef62c71a63f5ced2e2e92 | |
parent | [eventlog] Make more hw properties filterable (diff) | |
download | slx-admin-08853db4fa8d14dca94d4b932fe685b57ece7a81.tar.gz slx-admin-08853db4fa8d14dca94d4b932fe685b57ece7a81.tar.xz slx-admin-08853db4fa8d14dca94d4b932fe685b57ece7a81.zip |
[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.
-rw-r--r-- | modules-available/eventlog/inc/filterruleprocessor.inc.php | 7 |
1 files 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 '<invalid row index #' . $m[1] . '>'; + if (($m[2] ?? '') === '') { + $m[2] = 1; + } if (!isset($values[$m[1]][$m[2]])) return '<invalid column index #' . $m[2] . ' for row #' . $m[1] . '>'; $v = $values[$m[1]][$m[2]]; @@ -326,4 +329,4 @@ class FilterRuleProcessor return $a; } -}
\ No newline at end of file +} |