Repository navigation
Bound numeric character references before integer conversion - #452
Open
Ychris12138 wants to merge 1 commit into
Open
Ychris12138 wants to merge 1 commit into
Ychris12138 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Numeric character references with more than Python’s integer conversion limit (for example,
&#followed by 5,000 decimal digits) currently raise ValueError and abort conversion. Even a validAreference with enough leading zeros crashes.Strip leading zeros and bound the number of significant digits before calling int(). Out-of-range references continue to produce U+FFFD, and valid references, surrogate handling, and Windows-1252 substitutions retain their existing behavior. This covers a remaining oversized-input case related to #398.
Validation (Python 3.12): 212 tests passed, including 16 parameterized numeric-reference cases (six failed before the fix). Targeted Black/flake8, isort, mypy, and git diff --check passed. Full Black reports an existing formatting difference in config.py with the installed formatter; that file is unchanged. Flake8’s optional pydoclint rule DOC301 also reports the pre-existing HTML2Text class docstring.
AI-assisted implementation; all reported checks were executed locally.