changeset 839:85a61d0bd67b stable-0.5.x

Ported [1046:1047] to 0.5.x branch.
author cmlenz
date Tue, 17 Mar 2009 17:20:04 +0000
parents b87be223c83c
children b09f746b4881
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 @@
  * 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
--- 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()]
--- a/genshi/filters/tests/html.py
+++ b/genshi/filters/tests/html.py
@@ -317,6 +317,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