Fix an infinite loop issue parsing numbers outside of 0-9 fixes #639

This commit is contained in:
Timmy Welch 2024-04-29 10:09:59 -07:00
parent 235e62814f
commit 887c383229
2 changed files with 20 additions and 2 deletions

View File

@ -146,7 +146,8 @@ class Lexer:
return False
# AcceptRun consumes a run of runes from the valid set.
def accept_run(self, valid: str | Callable[[str], bool]) -> None:
def accept_run(self, valid: str | Callable[[str], bool]) -> bool:
initial = self.pos
if isinstance(valid, str):
while self.get() in valid:
continue
@ -155,11 +156,13 @@ class Lexer:
continue
self.backup()
return initial != self.pos
def scan_number(self) -> bool:
digits = "0123456789.,"
self.accept_run(digits)
if not self.accept_run(digits):
return False
if self.input[self.pos] == ".":
self.backup()
self.accept_run(str.isalpha)

View File

@ -438,6 +438,21 @@ names: list[tuple[str, str, dict[str, str | bool], tuple[bool, bool]]] = [
},
(False, False),
),
(
"Blue Beetle #½.cbr",
"½",
{
"archive": "cbr",
"issue": "½",
"series": "Blue Beetle",
"title": "",
"volume": "",
"year": "",
"remainder": "",
"issue_count": "",
},
(False, True),
),
(
"Monster Island vol. 2 #2.cbz",
"Example from userguide",