Module: check_mk
Branch: master
Commit: 6a9da332ff26d6b4d8367c41e2674d48512e12b0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6a9da332ff26d6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jun 1 09:16:55 2012 +0200
WATO view editor: Made new strip_bad_chars function work with unicode strings
---
web/htdocs/forms.py | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/web/htdocs/forms.py b/web/htdocs/forms.py
index 8151ea9..26b3f5d 100644
--- a/web/htdocs/forms.py
+++ b/web/htdocs/forms.py
@@ -98,7 +98,19 @@ def edit_dictionary(entries, value, focus=None, hover_help=True,
validate=None,
# New functions for painting forms
def strip_bad_chars(x):
- return "".join([c for c in x if c > ' ' and c <
'z']).translate(None, "'&;<>\"")
+ s = "".join([c for c in x if c > ' ' and c < 'z'])
+
+ if type(s) == unicode:
+ return s.translate({
+ ord(u"'"): None,
+ ord(u"&"): None,
+ ord(u";"): None,
+ ord(u"<"): None,
+ ord(u">"): None,
+ ord(u"\""): None,
+ })
+ else:
+ return s.translate(None, u"'&;<>\"")
def header(title, isopen = True, table_id = ""):
global g_header_open