Make WordPress Core

Ticket #46391: 46391.2.diff

File 46391.2.diff, 1021 bytes (added by achyuthajoy, 6 years ago)

Updated is_email local part regex according to RFC 5952

  • src/wp-includes/formatting.php

    diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php
    index b5c4982141..df0ce6ee22 100644
    a b function is_email( $email, $deprecated = false ) { 
    32863286
    32873287        // LOCAL PART
    32883288        // Test for invalid characters
    3289         if ( ! preg_match( '/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/', $local ) ) {
     3289        if ( ! preg_match( '/^(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00-\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22))(?:\.(?:(?:[\x21\x23-\x27\x2A\x2B\x2D\x2F-\x39\x3D\x3F\x5E-\x7E]+)|(?:\x22(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|(?:\x5C[\x00-\x7F]))*\x22)))*$/', $local ) ) {
    32903290                /** This filter is documented in wp-includes/formatting.php */
    32913291                return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
    32923292        }