Skip to content

Reject malformed extended Latin URL usernames - #597

Closed
adityajai119 wants to merge 1 commit into
python-validators:masterfrom
adityajai119:fix/url-unicode-auth-prefix
Closed

adityajai119 wants to merge 1 commit into
python-validators:masterfrom
adityajai119:fix/url-unicode-auth-prefix

Conversation

@adityajai119

Copy link
Copy Markdown

_username_regex() had an unanchored alternative that accepted any string starting with an extended Latin character as a URL username. As a result, malformed credentials such as http://Ā"evil@example.com/ were accepted by url().

The fix folds the extended Latin ranges into the anchored dot-atom alternative, so the whole username must match while extended Latin usernames remain valid.

Tests: two regression cases for malformed extended Latin usernames and one guard case for valid extended Latin usernames. tests/test_url.py: 331 passed. ruff check and ruff format --check: clean on both changed files.

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.

1 participant