Module: check_mk
Branch: master
Commit: 78ef0da5165baf08454d49aab2273f2fc3ebc661
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=78ef0da5165baf…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Dec 14 08:53:21 2016 +0100
Worked around recently introduced encoding issues in the GUI
Change-Id: I33dcaa7235aaf196cc326f0aa4f6e6ddbeaf8ba5
---
web/htdocs/htmllib.py | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/web/htdocs/htmllib.py b/web/htdocs/htmllib.py
index ff50d36..7d34b24 100644
--- a/web/htdocs/htmllib.py
+++ b/web/htdocs/htmllib.py
@@ -189,7 +189,23 @@ class HTML(object):
def __str__(self):
- return self.__bytebatzen__()
+ # Against the sense of the __str__() method, we need to return the value
+ # as unicode here. Why? There are many cases where something like
+ # "%s" % HTML(...) is done in the GUI code. This calls the __str__
function
+ # because the origin is a str() object. The call will then return a UTF-8
+ # encoded str() object. This brings a lot of compatbility issues to the code
+ # which can not be solved easily.
+ # To deal with this situation we need the implicit conversion from str to
+ # unicode that happens when we return a unicode value here. In all relevant
+ # cases this does exactly what we need. It would only fail if the origin
+ # string contained characters that can not be decoded with the ascii codec
+ # which is not relevant for us here.
+ #
+ # This is problematic:
+ # html.write("%s" % HTML("ä"))
+ #
+ # Bottom line: We should relly cleanup internal unicode/str handling.
+ return self.value
def __repr__(self):