# HG changeset patch # User cmlenz # Date 1237310404 0 # Node ID 85a61d0bd67b8829eb7b777b85135fd00bf5c007 # Parent b87be223c83c0294aaa000da48a5756007c583ed Ported [1046:1047] to 0.5.x branch. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ * Import statements inside function definitions in template code blocks no longer result in an UndefinedError when the imported name is accessed (ticket #276). + * Fixed handling of relative URLs with fragment identifiers containing colons + in the `HTMLSanitizer` (ticket #274). Version 0.5.1 diff --git a/genshi/filters/html.py b/genshi/filters/html.py --- a/genshi/filters/html.py +++ b/genshi/filters/html.py @@ -332,6 +332,8 @@ :rtype: `bool` :since: version 0.4.3 """ + if '#' in uri: + uri = uri.split('#', 1)[0] # Strip out the fragment identifier if ':' not in uri: return True # This is a relative URI chars = [char for char in uri.split(':', 1)[0] if char.isalnum()] diff --git a/genshi/filters/tests/html.py b/genshi/filters/tests/html.py --- a/genshi/filters/tests/html.py +++ b/genshi/filters/tests/html.py @@ -317,6 +317,9 @@ html = HTML('fo
o
') self.assertEquals(u'fo
o
', unicode(html | HTMLSanitizer())) + html = HTML('foo') + self.assertEquals(u'foo', + unicode(html | HTMLSanitizer())) def test_sanitize_escape_text(self): html = HTML('fo&')