Package: genshi / 0.6-3

fix_tests_failure_with_python27.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Description: Two tests which used to fail in earlier Pythons, now succeed in
 Python 2.7.3.  Adjust the tests to check for success in order to fix a FTBFS
 in Ubuntu 12.10.
Author: Barry Warsaw <barry@ubuntu.com>, Arnaud Fontaine <arnau@debian.org>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/genshi/+bug/935516
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=661441
Bug: http://genshi.edgewall.org/ticket/500
Bug: http://genshi.edgewall.org/ticket/501

Index: genshi-0.6/genshi/filters/tests/html.py
===================================================================
--- genshi-0.6.orig/genshi/filters/tests/html.py	2010-04-22 21:09:52.000000000 +0900
+++ genshi-0.6/genshi/filters/tests/html.py	2012-11-24 14:35:02.116021695 +0900
@@ -365,9 +365,24 @@
         self.assertEquals('', (html | HTMLSanitizer()).render())
         html = HTML('<SCRIPT SRC="http://example.com/"></SCRIPT>')
         self.assertEquals('', (html | HTMLSanitizer()).render())
-        self.assertRaises(ParseError, HTML, '<SCR\0IPT>alert("foo")</SCR\0IPT>')
-        self.assertRaises(ParseError, HTML,
-                          '<SCRIPT&XYZ SRC="http://example.com/"></SCRIPT>')
+
+        # Before Python 2.7.3, HTMLParser() raises a ParseError
+        try:
+            html = HTML('<SCR\0IPT>alert("foo")</SCR\0IPT>')
+        except ParseError:
+            pass
+        else:
+            self.assertEquals('&lt;SCR\x00IPT&gt;alert("foo")',
+                              (html | HTMLSanitizer()).render())
+
+        # Before Python 2.7.3, HTMLParser() raises a ParseError
+        try:
+            html = HTML('<SCRIPT&XYZ SRC="http://example.com/"></SCRIPT>')
+        except ParseError:
+            pass
+        else:
+            self.assertEquals('&lt;SCRIPT&amp;XYZ; SRC="http://example.com/"&gt;',
+                              (html | HTMLSanitizer()).render())
 
     def test_sanitize_remove_onclick_attr(self):
         html = HTML('<div onclick=\'alert("foo")\' />')
@@ -437,9 +452,13 @@
         # Case-insensitive protocol matching
         html = HTML('<IMG SRC=\'JaVaScRiPt:alert("foo")\'>')
         self.assertEquals('<img/>', (html | HTMLSanitizer()).render())
-        # Grave accents (not parsed)
-        self.assertRaises(ParseError, HTML,
-                          '<IMG SRC=`javascript:alert("RSnake says, \'foo\'")`>')
+        # Grave accents. Before Python 2.7.3, HTMLParser() raises a ParseError
+        try:
+            html = HTML('<IMG SRC=`javascript:alert("RSnake says, \'foo\'")`>')
+        except ParseError:
+            pass
+        else:
+            self.assertEquals('<img/>', (html | HTMLSanitizer()).render())
         # Protocol encoded using UTF-8 numeric entities
         html = HTML('<IMG SRC=\'&#106;&#97;&#118;&#97;&#115;&#99;&#114;&#105;'
                     '&#112;&#116;&#58;alert("foo")\'>')