Module: check_mk
Branch: master
Commit: 974ee7c732125416fbe51adfb2ae999de479d651
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=974ee7c7321254…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 19 15:16:54 2016 +0100
Fixed various problems related to our HTML class.
Change-Id: If56586756f95090b54713e4b098ebb16b2508cda
---
web/htdocs/htmllib.py | 34 ++++++++++++++++++++++++----------
web/htdocs/views.py | 2 +-
2 files changed, 25 insertions(+), 11 deletions(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index 4bb3483..3322ded 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -252,26 +252,40 @@ class HTML(object):
return self._ensure_unicode(item) in self.value
- def count(self, item):
- return self.value.count(self._ensure_unicode(item))
+ def count(self, sub, *args):
+ return self.value.count(self._ensure_unicode(sub), *args)
- def index(self, item):
- return self.value.index(self._ensure_unicode(item))
+ def index(self, sub, *args):
+ return self.value.index(self._ensure_unicode(sub), *args)
- def lstrip(self, stripstr):
- return HTML(self.value.lstrip(self._ensure_unicode(stripstr)))
+ def lstrip(self, *args):
+ args = tuple(map(self._ensure_unicode, args[:1])) + args[1:]
+ return HTML(self.value.lstrip(*args))
- def rstrip(self, stripstr):
- return HTML(self.value.rstrip(self._ensure_unicode(stripstr)))
+ def rstrip(self, *args):
+ args = tuple(map(self._ensure_unicode, args[:1])) + args[1:]
+ return HTML(self.value.rstrip(*args))
- def strip(self, stripstr):
- return HTML(self.value.strip(self._ensure_unicode(stripstr)))
+ def strip(self, *args):
+ args = tuple(map(self._ensure_unicode, args[:1])) + args[1:]
+ return HTML(self.value.strip(*args))
+ def lower(self):
+ return HTML(self.value.lower())
+
+
+ def upper(self):
+ return HTML(self.value.upper())
+
+
+ def startswith(self, prefix, *args):
+ return self.value.startswith(self._ensure_unicode(prefix), *args)
+
__builtin__.HTML = HTML
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index b25de82..dc69805 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -782,7 +782,7 @@ class Cell(object):
# images, but all that we need for showing simple icons.
# Current limitation: *one* image
if txt.lower().startswith("<img"):
- img_filename =
re.sub('.*src=["\']([^\'"]*)["\'].*', "\\1",
txt)
+ img_filename =
re.sub('.*src=["\']([^\'"]*)["\'].*', "\\1",
str(txt))
img_path = find_htdocs_image_path(img_filename)
if img_path:
txt = ("icon", img_path)