Merge pull request #184 from stanhu/trim-trailing-spaces
Ignore spaces in authorized emails list
This commit is contained in:
commit
613a342115
@ -53,7 +53,8 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
|
|||||||
}
|
}
|
||||||
updated := make(map[string]bool)
|
updated := make(map[string]bool)
|
||||||
for _, r := range records {
|
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))
|
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
|
||||||
}
|
}
|
||||||
|
@ -147,3 +147,16 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
|
|||||||
t.Error("validated domains are not lower-cased")
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user