Skip to content

Commit 6cb006a

Browse files
committed
Make sure lxml unesacpes xml names properly
1 parent 1442bad commit 6cb006a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/html5lib/ihatexml.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,14 @@ def listToRegexpStr(charList):
7272
rv = []
7373
for item in charList:
7474
if item[0] == item[1]:
75-
rv.append(intToUnicodeStr(item[0]))
75+
rv.append(unichar(item[0]))
7676
else:
77-
rv.append(intToUnicodeStr(item[0]) + "-" + intToUnicodeStr(item[1]))
78-
return "[%s]"%"|".join(rv)
77+
rv.append(unichar(item[0]) + "-" + unichar(item[1]))
78+
return "[%s]"%"".join(rv)
7979

8080
def hexToInt(hex_str):
8181
return int(hex_str, 16)
8282

83-
def intToUnicodeStr(intValue):
84-
#There must be a better (non-evil) way to do this
85-
return escapeRegexp(eval(r"u'\u%s'"%hex(intValue)[2:].rjust(4, "0")))
86-
8783
def escapeRegexp(string):
8884
specialCharacters = (".", "^", "$", "*", "+", "?", "{", "}",
8985
"[", "]", "|", "(", ")", "-")

src/html5lib/treebuilders/etree_lxml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,12 @@ def __init__(self, name, namespace):
203203
self._attributes = Attributes(self)
204204

205205
def _setName(self, name):
206-
self._name = filter.coerceElement(name)
206+
self._name = filter.coerceElement(name)
207207
self._element.tag = self._getETreeTag(
208208
self._name, self._namespace)
209209

210210
def _getName(self):
211-
return self._name
211+
return filter.fromXmlName(self._name)
212212

213213
name = property(_getName, _setName)
214214

0 commit comments

Comments
 (0)