diff --git a/linkcheck/HtmlParser/htmllib.py b/linkcheck/HtmlParser/htmllib.py index f116435f..819d4fa9 100644 --- a/linkcheck/HtmlParser/htmllib.py +++ b/linkcheck/HtmlParser/htmllib.py @@ -199,9 +199,19 @@ def quote_attrval (s): @return: the quoted HTML attribute @rtype: string """ - s = s.replace('&', "&") - s = s.replace('"', """) - return s + res = [] + for c in s: + if ord(c) <= 127: + # ASCII + if c == u'&': + res.append(u"&") + elif c == u'"': + res.append(u""") + else: + res.append(c) + else: + res.append(u"&#%d;" % ord(c)) + return u"".join(res) def quote_val (s):