From 3d4e60f2835e4d85fd357c182656d3eca534f2ff Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Fri, 3 Mar 2023 09:15:38 +0100 Subject: Prevent lxml.objectify from accepting non-decimal digit characters as integers/numbers and from representing them as IntElement. --- src/lxml/objectify.pyx | 2 +- src/lxml/tests/test_objectify.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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): t f + ²²²² 12_34 1.2_34 34E -- cgit v1.2.1