Module: check_mk
Branch: master
Commit: 388775dd40198629fecec474b14dbbd20f3b013d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=388775dd401986…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Oct 29 11:42:54 2013 +0100
FIX: fix bug with missing services in WATO inventory
---
web/htdocs/html_mod_python.py | 2 +-
web/htdocs/htmllib.py | 13 +++++++++++++
web/htdocs/wato.py | 9 ++++++---
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/web/htdocs/html_mod_python.py b/web/htdocs/html_mod_python.py
index e794044..fd8a17a 100644
--- a/web/htdocs/html_mod_python.py
+++ b/web/htdocs/html_mod_python.py
@@ -3,7 +3,7 @@ import htmllib
import os, time, config, weblib, re
import defaults
-varname_regex = re.compile('^[\w\d_-]+$')
+varname_regex = re.compile('^[\w\d_.%+]+$')
class html_mod_python(htmllib.html):
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index c26a0da..7101834 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -1117,6 +1117,19 @@ class html:
ret += c
return ret
+ # Escape a variable name so that it only uses allowed charachters for URL variables
+ def varencode(self, varname):
+ if varname == None:
+ return "None"
+
+ ret = ""
+ for c in varname:
+ if not c.isdigit() and not c.isalnum() and c != "_":
+ ret += "%%%02x" % ord(c)
+ else:
+ ret += c
+ return ret
+
def u8(self, c):
if ord(c) > 127:
return "&#%d;" % ord(c)
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d08f172..623ab32 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2204,14 +2204,17 @@ def mode_inventory(phase, firsttime):
for st, ct, checkgroup, item, paramstring, params, descr, state, output,
perfdata in table:
if (html.has_var("_cleanup") or
html.has_var("_fixall")) \
and st in [ "vanished", "obsolete" ]:
+ html.debug("%s: %s/%s" % (st, ct, item))
pass
elif (html.has_var("_activate_all") or
html.has_var("_fixall")) \
and st == "new":
active_checks[(ct, item)] = paramstring
else:
- varname = "_%s_%s" % (ct, item)
+ varname = "_%s_%s" % (ct, html.varencode(item))
if html.var(varname, "") != "":
active_checks[(ct, item)] = paramstring
+ else:
+ html.debug("Ausgelassen: %s/%s (varname: %s, value:
%s)" % (ct, item, varname, html.var(varname)))
check_mk_automation(host[".siteid"], "set-autochecks",
[hostname], active_checks)
if host.get("inventory_failed"):
@@ -2370,8 +2373,8 @@ def show_service_table(host, firsttime):
# Temporary ignore checkbox
html.write("<td>")
if checkbox != None:
- varname = "_%s_%s" % (ct, item)
- html.checkbox(varname, checkbox, add_attr =
['title="%s"' % _('Temporary ignore this service')])
+ varname = "_%s_%s" % (ct, html.varencode(item))
+ html.checkbox(varname, checkbox, add_attr =
['title="%s"' % _('Temporarily ignore this service')])
html.write("</td>")
html.write("</tr>\n")