changeset 837:44b633a0c6a9

Fix for #274.
author cmlenz
date Tue, 17 Mar 2009 15:10:47 +0000
parents ec96500c4dc3
children 80bce2f6f9fe
files ChangeLog genshi/filters/html.py genshi/filters/tests/html.py
diffstat 3 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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()]
--- a/genshi/filters/tests/html.py
+++ b/genshi/filters/tests/html.py
@@ -313,6 +313,9 @@
         html = HTML('<a href="#">fo<br />o</a>')
         self.assertEquals(u'<a href="#">fo<br/>o</a>',
                           unicode(html | HTMLSanitizer()))
+        html = HTML('<a href="#with:colon">foo</a>')
+        self.assertEquals(u'<a href="#with:colon">foo</a>',
+                          unicode(html | HTMLSanitizer()))
 
     def test_sanitize_escape_text(self):
         html = HTML('<a href="#">fo&amp;</a>')
Copyright (C) 2012-2017 Edgewall Software