quote attributes with unicode entity escapes

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3039 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2006-02-02 21:40:57 +00:00
parent 75be4d0bb6
commit a3e4780b38

View file

@ -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"&amp;")
elif c == u'"':
res.append(u"&quot;")
else:
res.append(c)
else:
res.append(u"&#%d;" % ord(c))
return u"".join(res)
def quote_val (s):