Repository navigation
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.
is_alpha_number() hands its argument straight to _maybe_strip_extension() with no length limit, unlike parse() which rejects anything over _MAX_INPUT_STRING_LENGTH. _EXTN_PATTERN is searched with a trailing $ anchor and every alternative starts with a separator run ([ \u00A0\t,]* or [- ]+), so for a long run of spaces or commas each start position scans to the end of the string before failing. That makes the call quadratic: is_alpha_number("800" + " " * n) takes about 0.15s at n=2000, 2.4s at 8000, 9.7s at 16000 and 57s at 32000 on CPython 3.9, so a few KB of form input pins a worker for seconds. A string longer than 250 chars can't be parsed, so it can't be a valid vanity number either; is_alpha_number now returns False for it before any regex work (0.000s for the same inputs). The cap lives in is_alpha_number because it is the only public entry point that reaches _maybe_strip_extension() with unbounded input; parse() already enforces the same limit.
The new assertion in testIsAlphaNumber returned True before the change (the padded string matched as a vanity number). make -C tools/python lint and test pass (308 tests).