You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if the "local part" of an email address is quoted, it may contain any number of @s, white-space characters and non printable unicode characters. Those three checks should be removed from the checkEmail String validation function to prevent erroneously rejecting compliant (although admittedly very weird) email addresses:
// Pretty basic validation, but should work for most cases and is not
// too strict to break things.
//
// Still better than obscure regex or std `mail.ParseAddress`.
var (
gotAtbool
lastrune
)
fori, r:=rangev {
ifunicode.IsSpace(r) {
returnerrors.Errorf("space character (%U)", r)
}
if!unicode.IsPrint(r) {
returnerrors.Errorf("not printable character (%U)", r)
}
last=r
ifr!='@' {
continue
}
ifgotAt {
returnerrors.New(`got @ multiple times`)
}
ifi==0 {
returnerrors.New(`got @ at start`)
}
gotAt=true
}
iflast=='@' {
returnerrors.New("@ at end")
}
if!gotAt {
returnerrors.New(`no @`)
}
returnnil
}
additionally, you can theoretically introduce a min/max length validation according to https://www.rfc-editor.org/errata/eid1003, though that may be covered by explicitly setting minLength and maxLength
The text was updated successfully, but these errors were encountered:
if the "local part" of an email address is quoted, it may contain any number of
@
s, white-space characters and non printable unicode characters. Those three checks should be removed from the checkEmail String validation function to prevent erroneously rejecting compliant (although admittedly very weird) email addresses:ogen/validate/string.go
Lines 63 to 99 in 8aafb42
additionally, you can theoretically introduce a min/max length validation according to https://www.rfc-editor.org/errata/eid1003, though that may be covered by explicitly setting
minLength
andmaxLength
The text was updated successfully, but these errors were encountered: