Merge pull request #2611 from tshinnic/svglib_parser_real_number_format
Handle one more valid real number format in svgLib parse_path()
This commit is contained in:
commit
b488d10768
@ -16,10 +16,13 @@ ARC_COMMANDS = set("Aa")
|
|||||||
UPPERCASE = set('MZLHVCSQTA')
|
UPPERCASE = set('MZLHVCSQTA')
|
||||||
|
|
||||||
COMMAND_RE = re.compile("([MmZzLlHhVvCcSsQqTtAa])")
|
COMMAND_RE = re.compile("([MmZzLlHhVvCcSsQqTtAa])")
|
||||||
|
|
||||||
|
# https://www.w3.org/TR/css-syntax-3/#number-token-diagram
|
||||||
|
# but -6.e-5 will be tokenized as "-6" then "-5" and confuse parsing
|
||||||
FLOAT_RE = re.compile(
|
FLOAT_RE = re.compile(
|
||||||
r"[-+]?" # optional sign
|
r"[-+]?" # optional sign
|
||||||
r"(?:"
|
r"(?:"
|
||||||
r"(?:0|[1-9][0-9]*)(?:\.[0-9]+(?:[eE][-+]?[0-9]+)?)?" # int/float
|
r"(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][-+]?[0-9]+)?" # int/float
|
||||||
r"|"
|
r"|"
|
||||||
r"(?:\.[0-9]+(?:[eE][-+]?[0-9]+)?)" # float with leading dot (e.g. '.42')
|
r"(?:\.[0-9]+(?:[eE][-+]?[0-9]+)?)" # float with leading dot (e.g. '.42')
|
||||||
r")"
|
r")"
|
||||||
|
@ -280,6 +280,15 @@ def test_exponents():
|
|||||||
|
|
||||||
assert pen.value == expected
|
assert pen.value == expected
|
||||||
|
|
||||||
|
pen = RecordingPen()
|
||||||
|
parse_path("M-3e38 3E+38L-3E-38,3e-38", pen)
|
||||||
|
expected = [
|
||||||
|
("moveTo", ((-3e+38, 3e+38),)),
|
||||||
|
("lineTo", ((-3e-38, 3e-38),)),
|
||||||
|
("endPath", ()),
|
||||||
|
]
|
||||||
|
|
||||||
|
assert pen.value == expected
|
||||||
|
|
||||||
def test_invalid_implicit_command():
|
def test_invalid_implicit_command():
|
||||||
with pytest.raises(ValueError) as exc_info:
|
with pytest.raises(ValueError) as exc_info:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user