aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-12-28 21:37:38 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-12-28 21:37:38 -0800
commit00c12818c2981e3eb45533d518df85a5977923cd (patch)
treef3b4801d8b4db8cc22a4bbdde0f5cd7b3bef5f85
parentf158c946aa2e28529312e8730f561e85a5e0e4a1 (diff)
Normalize URLs in test suite.
This way we don't fail tests for legitimate variations in URL escaping/normalization policies. Closes #334.
-rw-r--r--test/normalize.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/test/normalize.py b/test/normalize.py
index 6eb4ec2..6073bf0 100644
--- a/test/normalize.py
+++ b/test/normalize.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from html.parser import HTMLParser
+import urllib
try:
from html.parser import HTMLParseError
@@ -61,7 +62,10 @@ class MyHTMLParser(HTMLParser):
attrs.sort()
for (k,v) in attrs:
self.output += " " + k
- if v != None:
+ if v in ['href','src']:
+ self.output += ("=" + '"' +
+ urllib.quote(urllib.unquote(v), safe='/') + '"')
+ elif v != None:
self.output += ("=" + '"' + cgi.escape(v,quote=True) + '"')
self.output += ">"
self.last_tag = tag