@@ -802,7 +802,7 @@ func searchLike(sql string, params []interface{}, match string, columns ...strin
|
||||
// definitely not cut out any valid address is to just check for
|
||||
// the presence of @, which is arguably the most important check
|
||||
// in this.
|
||||
var rxLooseEmail = regexp.MustCompile(`^[^\s@]+@[^\s@\.]\..+$`)
|
||||
var rxLooseEmail = regexp.MustCompile(`^[^\s@]+@[^\s@\.]+\..+$`)
|
||||
|
||||
func hostSearchLike(sql string, params []interface{}, match string, columns ...string) (string, []interface{}) {
|
||||
base, args := searchLike(sql, params, match, columns...)
|
||||
|
||||
@@ -781,7 +781,7 @@ func TestNewUsesRegisterTLS(t *testing.T) {
|
||||
require.Equal(t, "x509: certificate is not valid for any names, but wanted to match localhost", err.Error())
|
||||
}
|
||||
|
||||
func TestWhereFilterTeas(t *testing.T) {
|
||||
func TestWhereFilterTeams(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
testCases := []struct {
|
||||
@@ -939,3 +939,24 @@ func TestCompareVersions(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRxLooseEmail(t *testing.T) {
|
||||
testCases := []struct {
|
||||
str string
|
||||
match bool
|
||||
}{
|
||||
{"foo", false},
|
||||
{"", false},
|
||||
{"foo@example", false},
|
||||
{"foo@example.com", true},
|
||||
{"foo+bar@example.com", true},
|
||||
{"foo.bar@example.com", true},
|
||||
{"foo.bar@baz.example.com", true},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.str, func(t *testing.T) {
|
||||
assert.Equal(t, tc.match, rxLooseEmail.MatchString(tc.str))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user