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

Make ISEMAIL and ISURL more flexible for longer TLD #834

Merged
merged 5 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
14 changes: 9 additions & 5 deletions sandbox/grist/functions/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ def ISTEXT(value):
([A-Za-z0-9] # Each part of hostname must start with alphanumeric
([A-Za-z0-9-]*[A-Za-z0-9])?\. # May have dashes inside, but end in alphanumeric
)+
[A-Za-z]{2,6}$ # Restrict top-level domain to length {2,6}. Google seems
[A-Za-z]{2,24}$ # Restrict top-level domain to length {2,24} (theoretically,
# the max length is 63 bytes as per RFC 1034). Google seems
# to use a whitelist for TLDs longer than 2 characters.
""", re.UNICODE | re.VERBOSE)

Expand Down Expand Up @@ -289,7 +290,8 @@ def ISEMAIL(value):
>>> ISEMAIL("[email protected]")
False

More tests:
More tests: Google Sheets Grist
------------- -----
>>> ISEMAIL("[email protected]") # True, True
True
>>> ISEMAIL("[email protected]") # True, True
Expand All @@ -314,6 +316,10 @@ def ISEMAIL(value):
True
>>> ISEMAIL("Bob_O'[email protected]") # False, True
True
>>> ISEMAIL("[email protected]") # False, True
True
>>> ISEMAIL("[email protected]") # False, True
False
>>> ISEMAIL(u"фыва@mail.ru") # False, True
True
>>> ISEMAIL("[email protected]") # True, False
Expand All @@ -324,8 +330,6 @@ def ISEMAIL(value):
False
>>> ISEMAIL("[email protected]") # True, False
False
>>> ISEMAIL("[email protected]") # False, False
False
>>> ISEMAIL("!def!xyz%[email protected]") # False, False
False
>>> ISEMAIL("!#$%&'*+-/=?^_`.{|}[email protected]") # False, False
Expand Down Expand Up @@ -391,7 +395,7 @@ def ISEMAIL(value):
([A-Za-z0-9] # Each part of hostname must start with alphanumeric
([A-Za-z0-9-]*[A-Za-z0-9])?\. # May have dashes inside, but end in alphanumeric
)+
[A-Za-z]{2,6} # Restrict top-level domain to length {2,6}. Google seems
[A-Za-z]{2,24} # Restrict top-level domain to length {2,24}. Google seems
# to use a whitelist for TLDs longer than 2 characters.
([/?][-\w!#$%&'()*+,./:;=?@~]*)?$ # Notably, this excludes <, >, and ".
""", re.VERBOSE)
Expand Down
1 change: 1 addition & 0 deletions test/common/gutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ describe('gutil', function() {
assert.isTrue(gutil.isEmail('[email protected]'));
assert.isTrue(gutil.isEmail('[email protected]'));
assert.isTrue(gutil.isEmail('[email protected]'));
assert.isTrue(gutil.isEmail('[email protected]'));

assert.isFalse(gutil.isEmail('plainaddress'));
assert.isFalse(gutil.isEmail('@domain.com'));
Expand Down
Loading