-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Stricter unicode space check in email regex (with tests) #1316
Open
vesquen
wants to merge
3
commits into
go-playground:master
Choose a base branch
from
vesquen:stricter-unicode-space-check-in-email-regex
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8675,11 +8675,105 @@ func TestEmail(t *testing.T) { | |
errs = validate.Var(s, "email") | ||
Equal(t, errs, nil) | ||
|
||
s = `"test test"@email.com` // U+00A0 No-Break Space between quotes | ||
errs = validate.Var(s, "email") | ||
Equal(t, errs, nil) | ||
|
||
s = `"@email.com` | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+0020 regular space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+00A0 No-Break Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+1680 Ogham Space Mark | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2000 En Quad | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2001 Em Quad | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2002 En Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2003 Em Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2004 Three-Per-Em Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2005 Four-Per-Em Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2006 Six-Per-Em Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2007 Figure Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2008 Punctuation Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2009 Thin Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+200A Hair Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+2028 Line Separator | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+202F Narrow No-Break Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+205F Medium Mathematical Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
s = ` [email protected]` // U+3000 Ideographic Space | ||
errs = validate.Var(s, "email") | ||
NotEqual(t, errs, nil) | ||
AssertError(t, errs, "", "", "", "", "email") | ||
|
||
i := true | ||
errs = validate.Var(i, "email") | ||
NotEqual(t, errs, nil) | ||
|
@@ -12667,7 +12761,7 @@ func TestIsIso3166AlphaNumericEUValidation(t *testing.T) { | |
value interface{} | ||
expected bool | ||
}{ | ||
{752, true}, //Sweden | ||
{752, true}, // Sweden | ||
{"752", true}, | ||
{826, false}, // UK | ||
{"826", false}, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend replacing those test strings with code point values. This approach would make the string's exact contents immediately clear and unambiguous.
https://go.dev/play/p/YBWM1EUvXoR