Skip to content

Commit

Permalink
Ignore spaces in authorized emails list
Browse files Browse the repository at this point in the history
  • Loading branch information
Stan Hu committed Dec 23, 2015
1 parent beebf4d commit dd46428
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
}
updated := make(map[string]bool)
for _, r := range records {
updated[strings.ToLower(r[0])] = true
address := strings.ToLower(strings.TrimSpace(r[0]))
updated[address] = true
}
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
}
Expand Down
13 changes: 13 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,16 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
t.Error("validated domains are not lower-cased")
}
}

func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
vt := NewValidatorTest(t)
defer vt.TearDown()

vt.WriteEmails(t, []string{" foo.bar@example.com "})
domains := []string(nil)
validator := vt.NewValidator(domains, nil)

if !validator("foo.bar@example.com") {
t.Error("email should validate")
}
}

0 comments on commit dd46428

Please sign in to comment.