Skip to content

Commit 29e8f01

Browse files
authored
Merge pull request #350 from yozachar/workshop
patch: supported extended latin in username
2 parents ae6faea + af69a68 commit 29e8f01

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/validators/email.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ def email(
8484
)
8585
)
8686
if re.match(
87+
# extended latin
88+
r"(^[\u0100-\u017F\u0180-\u024F]"
8789
# dot-atom
88-
r"(^[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
90+
+ r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
8991
# quoted-string
90-
+ r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)',
92+
+ r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*"$)',
9193
username_part,
9294
re.IGNORECASE,
9395
)

src/validators/url.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
@lru_cache
1414
def _username_regex():
1515
return re.compile(
16+
# extended latin
17+
r"(^[\u0100-\u017F\u0180-\u024F]"
1618
# dot-atom
17-
r"(^[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
19+
+ r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$"
1820
# non-quoted-string
19-
+ r"|^([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*$)",
21+
+ r"|^([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*$)",
2022
re.IGNORECASE,
2123
)
2224

tests/test_email.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
("example@valid-with-hyphens.com",),
1818
("test@domain.with.idn.tld.उदाहरण.परीक्षा",),
1919
("email@localhost.in",),
20+
("Łókaść@email.com",),
21+
("łemłail@here.com",),
2022
("email@localdomain.org",),
2123
('"\\\011"@here.com',),
2224
],

0 commit comments

Comments
 (0)