# HG changeset patch # User cmlenz # Date 1237302647 0 # Node ID 44b633a0c6a90cfb7488e5f48075f69c37accba9 # Parent ec96500c4dc3195b9859dea8b75bbd9140dddc8e Fix for #274. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,8 @@ with Google App Engine. This, too, is the result of integrating work done by Marcin Kurczych during GSoC 2008. * Added caching in the serialization stage for improved performance. + * Fixed handling of relative URLs with fragment identifiers containing colons + in the `HTMLSanitizer` (ticket #274). Version 0.5.2 diff --git a/genshi/filters/html.py b/genshi/filters/html.py --- a/genshi/filters/html.py +++ b/genshi/filters/html.py @@ -327,6 +327,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 @@ -313,6 +313,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&')