Module: check_mk
Branch: master
Commit: e5c9b4be36fe0788987092fc594640622abeb786
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e5c9b4be36fe07…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Dec 4 13:53:57 2014 +0100
#1644 FIX Fixed matching dynamic number of regex match groups
Regexes and rewrites like this here lead into an exception when matching:
Regex: foo(bar|baz(abc|xyz)) (stuff to match and reference)
Rewrite: Service foo\1 said: \3
LogLine: foobar asasdsadxxxxx
---
.werks/1644 | 13 +++++++++++++
ChangeLog | 1 +
mkeventd/bin/mkeventd | 7 ++++++-
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/.werks/1644 b/.werks/1644
new file mode 100644
index 0000000..949d0e8
--- /dev/null
+++ b/.werks/1644
@@ -0,0 +1,13 @@
+Title: Fixed matching dynamic number of regex match groups
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417697483
+Class: fix
+
+Regexes and rewrites like this here lead into an exception when matching:
+
+Regex: foo(bar|baz(abc|xyz)) (stuff to match and reference)
+Rewrite: Service foo\1 said: \3
+LogLine: foobar asasdsadxxxxx
diff --git a/ChangeLog b/ChangeLog
index c97f8b2..cafe1e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -193,6 +193,7 @@
* 1531 FIX: Fixed exception in event history view when displaying CHANGESTATE events
* 1610 FIX: Hostname translation now also works for incoming SNMP traps
* 1643 FIX: Improved error handling of exceptions when processing log lines
+ * 1644 FIX: Fixed matching dynamic number of regex match groups...
Livestatus:
* 1613 FIX: Fixed invalid json format in Stats query with requested heaeders...
diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index 1850ece..2d13f05 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -199,7 +199,12 @@ def match(pattern, text, complete = True):
# Assume compiled regex
m = pattern.search(text)
if m:
- return m.groups()
+ groups = m.groups()
+ if None in groups:
+ # Remove None from result tuples and replace it with empty strings
+ return tuple([g != None and g or '' for g in groups])
+ else:
+ return groups
else:
return False