[checkmk-commits] Check_MK Git: check_mk: #2233 FIX Fixed WATO folder view and Host Tags search with HTML Entity encoding

Sven Rueß sr at mathias-kettner.de
Mon Apr 27 09:46:49 CEST 2015


Module: check_mk
Branch: master
Commit: 37d4c5ae0c625f9ea74596fb2bb9d536e4e91c5b
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=37d4c5ae0c625f9ea74596fb2bb9d536e4e91c5b

Author: Sven Rueß <sr at mathias-kettner.de>
Date:   Mon Apr 27 09:41:59 2015 +0200

#2233 FIX Fixed WATO folder view and Host Tags search with HTML Entity encoding

Fixed WATO folder view to show correct indent of folder structure again without
escaping HTML Entities.
Fixed Host Tags search to show correct operators without escaping HTML Entities.

---

 .werks/2233                    |   12 ++++++++++++
 ChangeLog                      |    1 +
 Makefile                       |    2 +-
 web/htdocs/htmllib.py          |   25 +++++++++++++++++++------
 web/plugins/visuals/filters.py |    2 +-
 web/plugins/visuals/wato.py    |    2 +-
 6 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/.werks/2233 b/.werks/2233
new file mode 100644
index 0000000..2d325b4
--- /dev/null
+++ b/.werks/2233
@@ -0,0 +1,12 @@
+Title: Fixed WATO folder view and Host Tags search with HTML Entity encoding
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1430120013
+
+Fixed WATO folder view to show correct indent of folder structure again without
+escaping HTML Entities.
+Fixed Host Tags search to show correct operators without escaping HTML Entities.
diff --git a/ChangeLog b/ChangeLog
index 7b65cb3..46960a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -412,6 +412,7 @@
     * 2168 FIX: Fixed automation actions with transid=-1 when using basic authentication
     * 2177 FIX: Host/Service statistics dashlets honor the site filter correctly now
     * 1957 FIX: Fixed default value for text input fields in notification plugins...
+    * 2233 FIX: Fixed WATO folder view and Host Tags search with HTML Entity encoding...
 
     WATO:
     * 1760 Added search form to manual checks page
diff --git a/Makefile b/Makefile
index ce7eee2..aa50058 100644
--- a/Makefile
+++ b/Makefile
@@ -31,7 +31,7 @@ CONFDIR	       	= /etc/$(NAME)
 LIBDIR	       	= $(PREFIX)/lib/$(NAME)
 DISTNAME       	= $(NAME)-$(VERSION)
 TAROPTS        	= --owner=root --group=root --exclude=.svn --exclude=*~ \
-		  --exclude=.gitignore --exclude=.*.swp --exclude=.f12
+		  --exclude=.gitignore --exclude=*.swp --exclude=.f12
 
 # File to pack into livestatus-$(VERSION).tar.gz
 LIVESTATUS_SOURCES = configure aclocal.m4 config.guess config.h.in config.sub \
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 857f142..c5bfe1a 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -559,9 +559,23 @@ class html:
         self.form_vars.append(varname)
 
     def sorted_select(self, varname, choices, deflt="", onchange=None, attrs = {}):
+        def sort_function(a, b):
+            aStr = bStr = ''
+
+            if isinstance(a[1], HTML):
+                aStr = a[1].value
+            else:
+                aStr = a[1]
+            if isinstance(b[1], HTML):
+                bStr = b[1].value
+            else:
+                bStr = b[1]
+
+            return cmp(aStr.lower(), bStr.lower())
+
         # Sort according to display texts, not keys
         sorted = choices[:]
-        sorted.sort(lambda a,b: cmp(a[1].lower(), b[1].lower()))
+        sorted.sort(sort_function)
         self.select(varname, sorted, deflt, onchange, attrs)
 
     # Choices is a list pairs of (key, title). They keys of the choices
@@ -572,15 +586,14 @@ class html:
         attrs.setdefault('size', 1)
         attributes = ' ' + ' '.join([ '%s="%s"' % (k, v) for k, v in attrs.iteritems() ])
 
-        self.write("<select%s name=\"%s\" id=\"%s\"%s>\n" %
-                             (onchange_code, varname, varname, attributes))
+        self.write("<select%s name=\"%s\" id=\"%s\"%s>\n" % (onchange_code, varname, varname, attributes))
         for value, text in choices:
             if value == None:
                 value = ""
-            sel = value == current and " selected" or ""
-            self.write("<option value=\"%s\"%s>%s</option>\n" %
+            sel = value == current and " SELECTED" or ""
+            self.write('<option value="%s"%s>%s</option>\n' %
                 (self.attrencode(value), sel, self.attrencode(text)))
-        self.write("</select>\n")
+        self.write('</select>\n')
         if varname:
             self.form_vars.append(varname)
 
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index 5fb04c8..255ecba 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -887,7 +887,7 @@ class FilterHostTags(Filter):
         groups = [ (e[0], e[1].lstrip("/") ) for e in config.wato_host_tags ]
         operators = [
             ("is", _("=")),
-            ("isnot", _("≠")),
+            ("isnot", HTML(_("≠"))),
         ]
 
         # replace unicode strings, before writing out as "json"
diff --git a/web/plugins/visuals/wato.py b/web/plugins/visuals/wato.py
index 4185f7d..f464219 100644
--- a/web/plugins/visuals/wato.py
+++ b/web/plugins/visuals/wato.py
@@ -88,7 +88,7 @@ class FilterWatoFile(Filter):
         else:
             title_prefix = ""
         self.path_to_tree[my_path] = folder["title"]
-        sel = [ (my_path , title_prefix + folder["title"]) ]
+        sel = [ (my_path , HTML(title_prefix + html.attrencode(folder["title"]))) ]
         sel += self.sublist(folder.get(".folders", {}), my_path, depth)
         return sel
 



More information about the checkmk-commits mailing list