Skip to content

Commit dd46428

Browse files
author
Stan Hu
committed
Ignore spaces in authorized emails list
1 parent beebf4d commit dd46428

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

validator.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ func (um *UserMap) LoadAuthenticatedEmailsFile() {
5353
}
5454
updated := make(map[string]bool)
5555
for _, r := range records {
56-
updated[strings.ToLower(r[0])] = true
56+
address := strings.ToLower(strings.TrimSpace(r[0]))
57+
updated[address] = true
5758
}
5859
atomic.StorePointer(&um.m, unsafe.Pointer(&updated))
5960
}

validator_test.go

+13
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,16 @@ func TestValidatorComparisonsAreCaseInsensitive(t *testing.T) {
147147
t.Error("validated domains are not lower-cased")
148148
}
149149
}
150+
151+
func TestValidatorIgnoreSpacesInAuthEmails(t *testing.T) {
152+
vt := NewValidatorTest(t)
153+
defer vt.TearDown()
154+
155+
vt.WriteEmails(t, []string{" [email protected] "})
156+
domains := []string(nil)
157+
validator := vt.NewValidator(domains, nil)
158+
159+
if !validator("[email protected]") {
160+
t.Error("email should validate")
161+
}
162+
}

0 commit comments

Comments
 (0)