diff --git a/gluon/sanitizer.py b/gluon/sanitizer.py index 728c4bee..da71d159 100644 --- a/gluon/sanitizer.py +++ b/gluon/sanitizer.py @@ -125,7 +125,7 @@ class XssCleaner(HTMLParser): bt += ' /' bt += '>' self.result += bt - self.open_tags.insert(0, tag) + if tag not in self.requires_no_close: self.open_tags.insert(0, tag) def handle_endtag(self, tag): bracketed = '' % tag diff --git a/gluon/tests/test_html.py b/gluon/tests/test_html.py index 27c7b725..27c46cbe 100644 --- a/gluon/tests/test_html.py +++ b/gluon/tests/test_html.py @@ -308,6 +308,9 @@ class TestBareHelpers(unittest.TestCase): # beware that the comparison is made on the XML repr self.assertEqual(XML('

HelloWorld

', sanitize=True), XML('

HelloWorld

')) + #bug check for the sanitizer for closing no-close tags + self.assertEqual(XML('

Test


Test


', sanitize=True), + XML('

Test


Test


')) def testTAG(self): self.assertEqual(TAG.first(TAG.second('test'), _key=3).xml(),