Commit a1b7f9e7 authored by bobbyrullo's avatar bobbyrullo

Merge pull request #190 from ericchiang/valid_email

user: fix bug in ValidEmail helper
parents b30cb7d2 137330b2
...@@ -163,10 +163,9 @@ func ValidEmail(email string) bool { ...@@ -163,10 +163,9 @@ func ValidEmail(email string) bool {
return false return false
} }
if address.Name != "" || address.Address == "" { // Has mail.ParseAddress parsed the entire string and only found a single
return false // address without a name?
} return address.Address == email
return true
} }
func ValidPassword(plaintext string) bool { func ValidPassword(plaintext string) bool {
......
...@@ -103,6 +103,9 @@ func TestValidEmail(t *testing.T) { ...@@ -103,6 +103,9 @@ func TestValidEmail(t *testing.T) {
{"r@r.com", true}, {"r@r.com", true},
{"Barry Gibbs <bg@example.com>", false}, {"Barry Gibbs <bg@example.com>", false},
{"", false}, {"", false},
{"invalidemail", false},
{"example@example.com example@example.com", false},
{"example@example.com Hello, 世界", false},
} }
for i, tt := range tests { for i, tt := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment