fix: Validate string before calling int() (#6268)

This commit is contained in:
Jennifer Richards 2023-09-13 17:29:16 -03:00 committed by GitHub
parent 8bc4507def
commit 69fd3a059e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -88,8 +88,9 @@ class XMLDraft(Draft):
# check the anchor next
anchor = ref.get("anchor").lower() # always give back lowercase
label = anchor.rstrip("0123456789") # remove trailing digits
if label in series:
number = int(anchor[len(label) :])
maybe_number = anchor[len(label) :]
if label in series and maybe_number.isdigit():
number = int(maybe_number)
return f"{label}{number}"
# if we couldn't find a match so far, try the seriesInfo