Module: check_mk
Branch: master
Commit: 16d4b4ad9a0e62c4df2cce15afe065af13db472b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=16d4b4ad9a0e62…
Author: Tom Baerwinkel <tb(a)mathias-kettner.de>
Date: Mon Feb 4 09:43:34 2019 +0100
7057 FIX Allow "coding" comment in notification scripts
Notification scripts can contain the name of the notification
script as a comment after the shebang and the optional encoding
comment. When the encoding comment contained only the word
"coding" but not "encoding" the encoding comment was accidentally
used as the title of the notification script. Now the regular
expression from
https://docs.python.org/2.7/reference/lexical_analysis.html
is used to recognize encoding comments. Therefore, "coding" and
"encoding" can now be used.
Change-Id: Ieb2151276a57452d75c3f010bbecaffb037becd1
---
.werks/7057 | 18 ++++++++++++++++++
cmk/gui/watolib/user_scripts.py | 3 ++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/.werks/7057 b/.werks/7057
new file mode 100644
index 0000000..fc071ee
--- /dev/null
+++ b/.werks/7057
@@ -0,0 +1,18 @@
+Title: Allow "coding" comment in notification scripts
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1549018644
+
+Notification scripts can contain the name of the notification
+script as a comment after the shebang and the optional encoding
+comment. When the encoding comment contained only the word
+"coding" but not "encoding" the encoding comment was accidentally
+used as the title of the notification script. Now the regular
+expression from
https://docs.python.org/2.7/reference/lexical_analysis.html
+is used to recognize encoding comments. Therefore, "coding" and
+"encoding" can now be used.
diff --git a/cmk/gui/watolib/user_scripts.py b/cmk/gui/watolib/user_scripts.py
index ba4303c..f38af8c 100644
--- a/cmk/gui/watolib/user_scripts.py
+++ b/cmk/gui/watolib/user_scripts.py
@@ -38,6 +38,7 @@
"""
import os
+import re
import cmk.utils.paths
@@ -76,7 +77,7 @@ def _load_user_scripts_from(adir):
lines = file(path)
lines.next()
line = lines.next().decode("utf-8").strip()
- if line.startswith("#") and "encoding:" in line:
+ if line.startswith("#") and
re.search(r'coding[=:]\s*([-\w.]+)', line):
line = lines.next().strip()
if line.startswith("#"):
info["title"] =
line.lstrip("#").strip().split("#", 1)[0]