"Françoise Lefèvre"@example.com
I'm reading RFC 5321 to try to actually understand what constitutes a valid email address -- and I'm probably making this a lot more difficult than it needs to be -- but this has been bugging me.
i.e., within a quoted string, any ASCII graphic or space is permitted without blackslash-quoting except double-quote and the backslash itself.
Does this mean that ASCII extended character sets are valid within quotes? Or does that imply standard ASCII table only?
EDIT - With the answers in mind, here's a simple jQuery validator that could work in supplement to the the plugin's built-in email validation to check the characters.
jQuery.validator.addMethod("ascii_email", function( value, element ) {
// In compliance with RFC 5321, this allows all standard printing ASCII characters in quoted text.
// Unquoted text must be ASCII-US alphanumeric or one of the following: ! # $ % & ' * + - / = ? ^ _ ` { | } ~
// @ and . get a free pass, as this is meant to be used together with the email validator
var result = this.optional(element) ||
(
/^[\u002a\u002b\u003d\u003f\u0040\u0020-\u0027\u002d-u002f\u0030-\u0039\u0041-\u005a\u005e-\u007e]+$/.test(value.replace(/(["])(?:\\\1|.)*?\1/, "")) &&
/^[\u0020-\u007e]+$/.test(value.match(/(["])(?:\\\1|.)*?\1/, ""))
);
return result;
}, "Invalid characters");
The plugin's built-in validation appears to be pretty good, except for catching invalid characters. Out of the test cases listed here it only disallows comments, folding whitespace and addresses lacking a TDL (ie: @localhost, @255.255.255.255) -- all of which I can easily live without.