diff --git a/gluon/html.py b/gluon/html.py index 73eae9b8..4adf287c 100644 --- a/gluon/html.py +++ b/gluon/html.py @@ -1419,20 +1419,21 @@ class LINK(DIV): class SCRIPT(DIV): - tag = 'script' + tag = b'script' + tagname = to_bytes(tag) def xml(self): (fa, co) = self._xml() - fa = to_native(fa) + fa = to_bytes(fa) # no escaping of subcomponents - co = '\n'.join([str(component) for component in + co = b'\n'.join([to_bytes(component) for component in self.components]) if co: # # return '<%s%s>' % (self.tag, fa, co, self.tag) - return '<%s%s>' % (self.tag, fa, co, self.tag) + return b'<%s%s>' % (self.tagname, fa, co, self.tagname) else: return DIV.xml(self) @@ -1440,18 +1441,19 @@ class SCRIPT(DIV): class STYLE(DIV): tag = 'style' + tagname = to_bytes(tag) def xml(self): (fa, co) = self._xml() - fa = to_native(fa) + fa = to_bytes(fa) # no escaping of subcomponents - co = '\n'.join([str(component) for component in + co = b'\n'.join([to_bytes(component) for component in self.components]) if co: # - return '<%s%s>' % (self.tag, fa, co, self.tag) + return b'<%s%s>' % (self.tagname, fa, co, self.tagname) else: return DIV.xml(self) diff --git a/gluon/tests/test_html.py b/gluon/tests/test_html.py index 26693efb..4cca19e2 100644 --- a/gluon/tests/test_html.py +++ b/gluon/tests/test_html.py @@ -340,18 +340,20 @@ class TestBareHelpers(unittest.TestCase): def test_SCRIPT(self): self.assertEqual(SCRIPT('<>', _a='1', _b='2').xml(), - '''''') self.assertEqual(SCRIPT('<>').xml(), - '''''') self.assertEqual(SCRIPT().xml(), b'') + self.assertEqual(SCRIPT(';').xml() + DIV().xml(), + b'
') def test_STYLE(self): self.assertEqual(STYLE('<>', _a='1', _b='2').xml(), - '') + b'') # Try to hit : return DIV.xml(self) self.assertEqual(STYLE().xml(), b'')