4 ms·
Practically, those W3C/WHATWG regexes probably are fine, but they aren't correct. For instance they fail to match the valid address c."@".t@gmail.com because th
by oinksoft 11y ago
Practically, those W3C/WHATWG regexes probably are fine, but they aren't correct. For instance they fail to match the valid address c."@".t@gmail.com because they don't handle quoted strings correctly. I'd expect they also match some invalid addresses. My understanding was that only a Perl regex can test an address against the standard: http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html
- Dylan16807 11y agoIt may be incorrect to reject that email, but it's good to reject that email.
- __david__ 11y agoWhy reject a perfectly valid email? Why do you get to thumb your nose at that particular one?
- Dylan16807 11y agoIt's only 'valid' because of the particular decisions made by someone writing a random RFC. There's next to no reason to allow quoted strings, and even less reason to allow a different character set inside of them. Email addresses do not need escape sequences.
- mikeash 11y agoDoesn't this sort of RFC typically summarize and codify real-world usage, rather than coming up with new stuff? If a feature is in there, I'd have thought it's because somebody uses it.
- pc86 11y agoAt some point you just have to reach the level of "Yeah... don't do that." I would suspect have "@" as part of your email probably approaches that line.
- mikeash 11y agoIt would be interesting to know the context. If this feature was already in a popular piece of software, then saying "don't do that" in your standard risks fragmenting things rather than codifying them, and that's no good either.
- kevin_thibedeau 11y agoWhere do you draw the line? I occasionally have valid GMail addresses with "+" in them rejected because someone wrote a crappy validator.
- Dylan16807 11y agoAllow all the characters that are supposed to be valid outside of quotation marks. Letters, numbers, .!#$%&'*+-/=?^_`{|}~ That way if you don't mind letting through double periods or domain segments having more than 63 characters, you can validate an email with two character classes separated by an @. The basic regex looks like [xx]+@[yy]+
- immibis 11y ago> It's only 'valid' because of the particular decisions made by someone writing a random RFC. You know that's exactly what "valid" means, when talking about something standardized, right? In HTML there's no reason to use " outside of an attribute value. Should browsers reject it?
- oh_sigh 11y agoI don't think gmail will let you register that email address.
- immibis 11y agoOkay then, c."@".t@someotherdomain.com