Skip to content

Bound numeric character references before integer conversion - #452

Open
Ychris12138 wants to merge 1 commit into
Alir3z4:masterfrom
Ychris12138:fix/bounded-numeric-entities
Open

Ychris12138 wants to merge 1 commit into
Alir3z4:masterfrom
Ychris12138:fix/bounded-numeric-entities

Conversation

@Ychris12138

Copy link
Copy Markdown

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 valid A reference 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.

Copilot AI balanced review requested due to automatic review settings October 9, 2026 03:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants