mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-13 09:03:11 +00:00
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:
parent
75be4d0bb6
commit
a3e4780b38
1 changed files with 13 additions and 3 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue