Skip to content

Commit 00c1281

Browse files
committed
Normalize URLs in test suite.
This way we don't fail tests for legitimate variations in URL escaping/normalization policies. Closes #334.
1 parent f158c94 commit 00c1281

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/normalize.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22
from html.parser import HTMLParser
3+
import urllib
34

45
try:
56
from html.parser import HTMLParseError
@@ -61,7 +62,10 @@ def handle_starttag(self, tag, attrs):
6162
attrs.sort()
6263
for (k,v) in attrs:
6364
self.output += " " + k
64-
if v != None:
65+
if v in ['href','src']:
66+
self.output += ("=" + '"' +
67+
urllib.quote(urllib.unquote(v), safe='/') + '"')
68+
elif v != None:
6569
self.output += ("=" + '"' + cgi.escape(v,quote=True) + '"')
6670
self.output += ">"
6771
self.last_tag = tag

0 commit comments

Comments
 (0)