Module: check_mk
Branch: master
Commit: 6f26532376e6f6891e6d88203c97e3d8191ee278
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6f26532376e6f6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Nov 18 13:39:20 2014 +0100
Handle non-Ascii charachters in bulk directory names correctly
---
modules/notify.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/modules/notify.py b/modules/notify.py
index f9d6164..89ac7a8 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1494,6 +1494,19 @@ def find_wato_folder(context):
def create_bulk_dirname(bulk_path):
dirname = notification_bulkdir + "/" + bulk_path[0] + "/" +
bulk_path[1] + "/"
dirname += ",".join([b.replace("/", "\\") for b in
bulk_path[2:]])
+
+ # Remove non-Ascii-characters by special %02x-syntax
+ try:
+ str(dirname)
+ except:
+ new_dirname = ""
+ for char in dirname:
+ if ord(char) <= 0 or ord(char) > 127:
+ new_dirname += "%%%04x" % ord(char)
+ else:
+ new_dirname += char
+ dirname = new_dirname
+
if not os.path.exists(dirname):
os.makedirs(dirname)
notify_log(" - created bulk directory %s" % dirname)