Skip to content

Commit

Permalink
Merge pull request #350 from yozachar/workshop
Browse files Browse the repository at this point in the history
patch: supported extended latin in username
  • Loading branch information
yozachar authored Apr 2, 2024
2 parents ae6faea + af69a68 commit 29e8f01
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
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

0 comments on commit 29e8f01

Please sign in to comment.