diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 21:37:38 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-12-28 21:37:38 -0800 |
commit | 00c12818c2981e3eb45533d518df85a5977923cd (patch) | |
tree | f3b4801d8b4db8cc22a4bbdde0f5cd7b3bef5f85 /test | |
parent | f158c946aa2e28529312e8730f561e85a5e0e4a1 (diff) |
Normalize URLs in test suite.
This way we don't fail tests for legitimate variations in
URL escaping/normalization policies.
Closes #334.
Diffstat (limited to 'test')
-rw-r--r-- | test/normalize.py | 6 |
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 |