From 00c12818c2981e3eb45533d518df85a5977923cd Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 28 Dec 2015 21:37:38 -0800 Subject: Normalize URLs in test suite. This way we don't fail tests for legitimate variations in URL escaping/normalization policies. Closes #334. --- test/normalize.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3