On 23/10/2010 22:16, Garrett Smith wrote:
On 10/22/10, Anne van Kesteren <[email protected]> wrote:
On Fri, 22 Oct 2010 19:44:42 +0200, Boris Zbarsky <[email protected]> wrote:
On 10/22/10 1:25 PM, Garrett Smith wrote:
What is wrong with splitting on comma, e.g.
var validAddressList = inp.value.split(",");
That depends on what meaning of "email address" is used here. Is:
"Zbarsky, Boris" <[email protected]>
a valid "email address"?
Not per HTML5.
Link:
http://www.w3.org/TR/2010/WD-html-markup-20101019/input.email.html
Quote:
A single e-mail address.
Any string that matches the following [ABNF] production:
1*( atext / "." ) "@" ldh-str 1*( "." ldh-str )
…where atext is as defined in [RFC 5322], and ldh-str is as
defined in [RFC 1034].
Definition of atext from RFC 5322:
atext = ALPHA / DIGIT / ; Printable US-ASCII
"!" / "#" / ; characters not including
"$" / "%" / ; specials. Used for atoms.
"&" / "'" /
"*" / "+" /
"-" / "/" /
"=" / "?" /
"^" / "_" /
"`" / "{" /
"|" / "}" /
"~"
ALPHA and DIGIT are themselves defined in RFC 5234 to be the letters A
to Z (upper-case or lower-case) and the digits 0 to 9 respectively.
Definition of ldh-str from RFC 1034:
<ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str>
<let-dig-hyp> ::= <let-dig> | "-"
<let-dig> ::= <letter> | <digit>
<letter> ::= any one of the 52 alphabetic characters A through Z in
upper case and a through z in lower case
<digit> ::= any one of the ten digits 0 through 9
In other words, the letters A to Z (upper-case or lower-case), the
digits 0 to 9 and the hyphen.
Therefore
"Zbarsky, Boris" <[email protected]>
is not a valid email address because the portion before the @ contains
characters that are not atext (namely, the quotation marks, the comma,
the spaces and the left angle bracket) or dots, and the portion after
the @ contains characters that are not ldh-str or dots (namely, the
right angle bracket).
[email protected] is, however, a valid email address.
Alex
--
Alex Bishop
[email protected]