Ticket #17433: 17433-4.diff
File 17433-4.diff, 2.9 KB (added by , 10 years ago) |
---|
-
src/wp-includes/formatting.php
2169 2169 // Split the domain into subs 2170 2170 $subs = explode( '.', $domain ); 2171 2171 2172 // Assume the domain will have at least two subs 2173 if ( 2 > count( $subs ) ) {2172 // Assume the domain will have at least two subs, whitelist localhost 2173 if ( 2 > count( $subs ) && 'localhost' !== strtolower( $domain ) ) { 2174 2174 /** This filter is documented in wp-includes/formatting.php */ 2175 2175 return apply_filters( 'is_email', false, $email, 'domain_no_periods' ); 2176 2176 } … … 2421 2421 // Split the domain into subs 2422 2422 $subs = explode( '.', $domain ); 2423 2423 2424 // Assume the domain will have at least two subs2425 if ( 2 > count( $subs ) ) {2426 /** This filter is documented in wp-includes/formatting.php */2427 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' );2428 }2429 2430 2424 // Create an array that will contain valid subs 2431 2425 $new_subs = array(); 2432 2426 … … 2444 2438 } 2445 2439 } 2446 2440 2447 // If there aren't 2 or more valid subs 2448 if ( 2 > count( $new_subs ) ) {2441 // If there aren't 2 or more valid subs, whitelist localhost 2442 if ( 2 > count( $new_subs ) && 'localhost' !== strtolower( $domain ) ) { 2449 2443 /** This filter is documented in wp-includes/formatting.php */ 2450 2444 return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); 2451 2445 } -
tests/phpunit/tests/formatting/IsEmail.php
9 9 "bob@example.com", 10 10 "phil@example.info", 11 11 "ace@204.32.222.14", 12 "kevin@many.subdomains.make.a.happy.man.edu" 12 "kevin@many.subdomains.make.a.happy.man.edu", 13 "sal@localhost", 13 14 ); 14 15 foreach ( $data as $datum ) { 15 16 $this->assertEquals( $datum, is_email( $datum ), $datum ); -
tests/phpunit/tests/formatting/SanitizeEmail.php
1 <?php 2 3 /** 4 * @group formatting 5 */ 6 class Tests_Formatting_SanitizeEmail extends WP_UnitTestCase { 7 function test_returns_the_unmodified_email_address_if_it_is_valid() { 8 $data = array( 9 "bob@example.com", 10 "phil@example.info", 11 "ace@204.32.222.14", 12 "kevin@many.subdomains.make.a.happy.man.edu", 13 "sal@localhost", 14 ); 15 foreach ( $data as $datum ) { 16 $this->assertEquals( $datum, sanitize_email( $datum ), $datum ); 17 } 18 } 19 }