Ticket #17433: 17433-3.diff
File 17433-3.diff, 3.0 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 subs 2425 if ( 2 > count( $subs ) ) {2424 // Assume the domain will have at least two subs, whitelist localhost 2425 if ( 2 > count( $subs ) && 'localhost' !== strtolower( $domain ) ) { 2426 2426 /** This filter is documented in wp-includes/formatting.php */ 2427 2427 return apply_filters( 'sanitize_email', '', $email, 'domain_no_periods' ); 2428 2428 } … … 2444 2444 } 2445 2445 } 2446 2446 2447 // If there aren't 2 or more valid subs 2448 if ( 2 > count( $new_subs ) ) {2447 // If there aren't 2 or more valid subs, whitelist localhost 2448 if ( 2 > count( $new_subs ) && 'localhost' !== strtolower( $domain ) ) { 2449 2449 /** This filter is documented in wp-includes/formatting.php */ 2450 2450 return apply_filters( 'sanitize_email', '', $email, 'domain_no_valid_subs' ); 2451 2451 } -
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 }