summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2023-03-03 09:15:38 +0100
committerStefan Behnel <stefan_ml@behnel.de>2023-03-03 09:15:38 +0100
commit3d4e60f2835e4d85fd357c182656d3eca534f2ff (patch)
tree494c189a5ec3c12fa4aeea4d968b09bc5ce18112
parent4f7d52741149056dd4addde65d6257a80f8ade9e (diff)
downloadpython-lxml-3d4e60f2835e4d85fd357c182656d3eca534f2ff.tar.gz
Prevent lxml.objectify from accepting non-decimal digit characters as integers/numbers and from representing them as IntElement.
-rw-r--r--src/lxml/objectify.pyx2
-rw-r--r--src/lxml/tests/test_objectify.py1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/lxml/objectify.pyx b/src/lxml/objectify.pyx
index 376695a8..791f2cf8 100644
--- a/src/lxml/objectify.pyx
+++ b/src/lxml/objectify.pyx
@@ -976,7 +976,7 @@ cdef _checkNumber(bytes_unicode s, bint allow_float):
cdef NumberParserState state = NPS_SPACE_PRE
for c in s:
- if c.isdigit() if (bytes_unicode is unicode) else c in b'0123456789':
+ if c in u'0123456789':
if state in (NPS_DIGITS, NPS_FRACTION, NPS_DIGITS_EXP):
pass
elif state in (NPS_SPACE_PRE, NPS_SIGN):
diff --git a/src/lxml/tests/test_objectify.py b/src/lxml/tests/test_objectify.py
index f50a3447..a62df852 100644
--- a/src/lxml/tests/test_objectify.py
+++ b/src/lxml/tests/test_objectify.py
@@ -2663,6 +2663,7 @@ class ObjectifyTestCase(HelperTestCase):
<s>t</s>
<s>f</s>
<s></s>
+ <s>²²²²</s>
<s>12_34</s>
<s>1.2_34</s>
<s>34E</s>