Index: wp-includes/formatting.php
===================================================================
--- wp-includes/formatting.php	(revision 44617)
+++ wp-includes/formatting.php	(working copy)
@@ -3242,95 +3242,139 @@
 }
 
 /**
- * Verifies that an email is valid.
- *
- * Does not grok i18n domains. Not RFC compliant.
- *
- * @since 0.71
- *
- * @param string $email      Email address to verify.
- * @param bool   $deprecated Deprecated.
- * @return string|bool Either false or the valid email address.
- */
+* Verifies that an email is valid.
+*
+* @since 0.71
+*
+* @param string $email      Email address to verify.
+* @param bool   $deprecated Deprecated.
+* @return string|bool Either false or the valid email address.
+*/
 function is_email( $email, $deprecated = false ) {
 	if ( ! empty( $deprecated ) ) {
 		_deprecated_argument( __FUNCTION__, '3.0.0' );
 	}
 
-	// Test for the minimum length the email can be
-	if ( strlen( $email ) < 6 ) {
-		/**
-		 * Filters whether an email address is valid.
-		 *
-		 * This filter is evaluated under several different contexts, such as 'email_too_short',
-		 * 'email_no_at', 'local_invalid_chars', 'domain_period_sequence', 'domain_period_limits',
-		 * 'domain_no_periods', 'sub_hyphen_limits', 'sub_invalid_chars', or no specific context.
-		 *
-		 * @since 2.8.0
-		 *
-		 * @param bool   $is_email Whether the email address has passed the is_email() checks. Default false.
-		 * @param string $email    The email address being checked.
-		 * @param string $context  Context under which the email was tested.
-		 */
-		return apply_filters( 'is_email', false, $email, 'email_too_short' );
+	switch( true ) {
+		case ( ! is_email_basics( $email ) ):
+			return apply_filters( 'is_email', false, $email );
+			break;
+		case ( is_email_rfc822(  $email ) ):
+			break;
+		case ( is_email_rfc2822( $email ) ):
+			break;
+		default:
+			return apply_filters( 'is_email', false, $email );
 	}
+	return $email;
+}
 
-	// Test for an @ character after the first position
-	if ( strpos( $email, '@', 1 ) === false ) {
-		/** This filter is documented in wp-includes/formatting.php */
-		return apply_filters( 'is_email', false, $email, 'email_no_at' );
-	}
+/**
+* Verifies that email fits with basics.
+* 
+*     the format of an email address is : local-part@domain-part
+*         the local  part may be up to 64 characters long and the domain may have a maximum of 255 characters.
+*         the domain part is a list of dot-separated DNS labels, each label being limited to a length of 63 characters
+*
+* @param string $email
+*/
+function is_email_basics( $email ) {
+	$parts = explode( '@', $email );
 
-	// Split out the local and domain parts
-	list( $local, $domain ) = explode( '@', $email, 2 );
-
-	// LOCAL PART
-	// Test for invalid characters
-	if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
-		/** This filter is documented in wp-includes/formatting.php */
-		return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
+	$domain_part = array_pop( $parts );
+	if ( is_numeric( $domain_part ) ) {
+		return false;
 	}
+	if ( strlen( $domain_part ) > 255 ) {
+		return false;
+	}
 
-	// DOMAIN PART
-	// Test for sequences of periods
-	if ( preg_match( '/\.{2,}/', $domain ) ) {
-		/** This filter is documented in wp-includes/formatting.php */
-		return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
+	$local_part  = implode( '@', $parts );
+	if ( strlen( $local_part ) > 64 ) {
+		return false;
 	}
 
-	// Test for leading and trailing periods and whitespace
-	if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
-		/** This filter is documented in wp-includes/formatting.php */
-		return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
+	$dots = explode( '.', $domain_part );
+	foreach( $dots as $dot ) {
+		if ( strlen( $dot ) > 63 ) {
+			return false;
+		}
 	}
+	return true;
+}
 
-	// Split the domain into subs
-	$subs = explode( '.', $domain );
-
-	// Assume the domain will have at least two subs
-	if ( 2 > count( $subs ) ) {
-		/** This filter is documented in wp-includes/formatting.php */
-		return apply_filters( 'is_email', false, $email, 'domain_no_periods' );
+/**
+*  Validates whether the value is a valid e-mail address.
+* 	In general, this validates e-mail addresses against the syntax in RFC 822, 
+*    with the exceptions that comments and whitespace folding and dotless domain names are not supported.
+*  [php.net]
+*
+* @param string $email
+*/
+function is_email_rfc822( $email ) {
+	if ( ! defined( 'FILTER_VALIDATE_EMAIL' ) ) {
+		return false;
 	}
+	if ( ! function_exists( 'filter_var' ) ) {
+		return false;
+	}
+	return ( filter_var( $email, FILTER_VALIDATE_EMAIL ) );
+}
 
-	// Loop through each sub
-	foreach ( $subs as $sub ) {
-		// Test for leading and trailing hyphens and whitespace
-		if ( trim( $sub, " \t\n\r\0\x0B-" ) !== $sub ) {
-			/** This filter is documented in wp-includes/formatting.php */
-			return apply_filters( 'is_email', false, $email, 'sub_hyphen_limits' );
-		}
+/**
+* Defines and applies the grammar to use for validation, implements the RFC 2822 (and friends) ABNF grammar definitions.
+*
+* @author     Fabien Potencier
+* @author     Chris Corbyn
+*
+* @param string $email
+*/
+function is_email_rfc2822( $email ) {
+	return ( preg_match( '/^' . is_email_rfc2822_grammar() . '$/D', $email ) );
+}
 
-		// Test for invalid characters
-		if ( ! preg_match( '/^[a-z0-9-]+$/i', $sub ) ) {
-			/** This filter is documented in wp-includes/formatting.php */
-			return apply_filters( 'is_email', false, $email, 'sub_invalid_chars' );
-		}
-	}
+/**
+* Refer to RFC 2822 for ABNF grammar 
+*
+* @author     Fabien Potencier
+* @author     Chris Corbyn
+*
+*/
+function is_email_rfc2822_grammar() {
+	//All basic building blocks
+	$g['NO-WS-CTL'] 	= '[\x01-\x08\x0B\x0C\x0E-\x19\x7F]';
+	$g['WSP'] 			= '[ \t]';
+	$g['CRLF'] 		= '(?:\r\n)';
+	$g['FWS'] 			= '(?:(?:' . $g['WSP'] . '*' . $g['CRLF'] . ')?' . $g['WSP'] . ')';
+	$g['text'] 		= '[\x00-\x08\x0B\x0C\x0E-\x7F]';
+	$g['quoted-pair'] 	= '(?:\\\\' . $g['text'] . ')';
+	$g['ctext'] 		= '(?:' . $g['NO-WS-CTL'] . '|[\x21-\x27\x2A-\x5B\x5D-\x7E])';
+	//Uses recursive PCRE (?1) -- 
+	$g['ccontent'] 		= '(?:' . $g['ctext'] . '|' . $g['quoted-pair'] . '|(?1))';
+	$g['comment'] 		= '(\((?:' . $g['FWS'] . '|' . $g['ccontent']. ')*' . $g['FWS'] . '?\))';
+	$g['CFWS'] 		= '(?:(?:' . $g['FWS'] . '?' . $g['comment'] . ')*(?:(?:' . $g['FWS'] . '?' . $g['comment'] . ')|' . $g['FWS'] . '))';
+	$g['qtext'] 		= '(?:' . $g['NO-WS-CTL'] . '|[\x21\x23-\x5B\x5D-\x7E])';
+	$g['qcontent'] 		= '(?:' . $g['qtext'] . '|' . $g['quoted-pair'] . ')';
+	$g['quoted-string'] 	= '(?:' . $g['CFWS'] . '?"' . '(' . $g['FWS'] . '?' . $g['qcontent'] . ')*' . $g['FWS'] . '?"' . $g['CFWS'] . '?)';
+	$g['atext'] 		= '[a-zA-Z0-9!#\$%&\'\*\+\-\/=\?\^_`\{\}\|~]';
+	$g['atom'] 		= '(?:' . $g['CFWS'] . '?' . $g['atext'] . '+' . $g['CFWS'] . '?)';
+	$g['dot-atom-text'] 	= '(?:' . $g['atext'] . '+' . '(\.' . $g['atext'] . '+)*)';
+	$g['dot-atom'] 		= '(?:' . $g['CFWS'] . '?' . $g['dot-atom-text'] . '+' . $g['CFWS'] . '?)';
+	$g['word'] 		= '(?:' . $g['atom'] . '|' . $g['quoted-string'] . ')';
+	$g['phrase'] 		= '(?:' . $g['word'] . '+?)';
+	$g['no-fold-quote'] 	= '(?:"(?:' . $g['qtext'] . '|' . $g['quoted-pair'] . ')*")';
+	$g['dtext'] 		= '(?:' . $g['NO-WS-CTL'] . '|[\x21-\x5A\x5E-\x7E])';
+	$g['no-fold-literal']	= '(?:\[(?:' . $g['dtext'] . '|' . $g['quoted-pair'] . ')*\])';
+	//Message IDs
+	$g['id-left'] 		= '(?:' . $g['dot-atom-text'] . '|' . $g['no-fold-quote'] . ')';
+	$g['id-right'] 		= '(?:' . $g['dot-atom-text'] . '|' . $g['no-fold-literal'] . ')';
+	//Addresses, mailboxes and paths
+	$g['local-part'] 	= '(?:' . $g['dot-atom'] . '|' . $g['quoted-string'] . ')';
+	$g['dcontent'] 		= '(?:' . $g['dtext'] . '|' . $g['quoted-pair'] . ')';
+	$g['domain-literal'] 	= '(?:' . $g['CFWS'] . '?\[(' . $g['FWS'] . '?' . $g['dcontent'] . ')*?' . $g['FWS'] . '?\]' . $g['CFWS'] . '?)';
+	$g['domain'] 		= '(?:' . $g['dot-atom'] . '|' . $g['domain-literal'] . ')';
 
-	// Congratulations your email made it!
-	/** This filter is documented in wp-includes/formatting.php */
-	return apply_filters( 'is_email', $email, $email, null );
+	return '(?:' . $g['local-part'] . '@' . $g['domain'] . ')';
 }
 
 /**
