Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: supported extended latin in username #350

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/validators/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ def email(
)
)
if re.match(
# extended latin
r"(^[\u0100-\u017F\u0180-\u024F]"
# dot-atom
r"(^[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
+ r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
# quoted-string
+ r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)',
+ r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*"$)',
username_part,
re.IGNORECASE,
)
Expand Down
6 changes: 4 additions & 2 deletions src/validators/url.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
@lru_cache
def _username_regex():
return re.compile(
# extended latin
r"(^[\u0100-\u017F\u0180-\u024F]"
# dot-atom
r"(^[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
+ r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
# non-quoted-string
+ r"|^([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*$)",
+ r"|^([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*$)",
re.IGNORECASE,
)

Expand Down
2 changes: 2 additions & 0 deletions tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
("[email protected]",),
("[email protected].उदाहरण.परीक्षा",),
("[email protected]",),
("Łókaść@email.com",),
("łemł[email protected]",),
("[email protected]",),
('"\\\011"@here.com',),
],
Expand Down