diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php
index 56d5fd9f43..c4fa380fc0 100644
a
|
b
|
function wp_get_direct_php_update_url() { |
7559 | 7559 | return $direct_update_url; |
7560 | 7560 | } |
7561 | 7561 | |
| 7562 | /** |
| 7563 | * Encode this url, like rawurlencode. If it ends in a period, replace that with %2E. |
| 7564 | * This is done because gmail doesn't interpret it right otherwise. |
| 7565 | * See https://core.trac.wordpress.org/ticket/42957 for background. |
| 7566 | * |
| 7567 | * @param string $url Any url. |
| 7568 | * @return string Encoded url. |
| 7569 | */ |
| 7570 | function wp_half_baked_url_encode( $url ) { |
| 7571 | return preg_replace( '/\.$/', '%2E', rawurlencode( $url ) ); |
| 7572 | } |
| 7573 | |
7562 | 7574 | /** |
7563 | 7575 | * Display a button directly linking to a PHP update process. |
7564 | 7576 | * |
diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php
index c53a723fc4..2a148d2d82 100644
a
|
b
|
if ( ! function_exists( 'wp_new_user_notification' ) ) : |
2082 | 2082 | /* translators: %s: User login. */ |
2083 | 2083 | $message = sprintf( __( 'Username: %s' ), $user->user_login ) . "\r\n\r\n"; |
2084 | 2084 | $message .= __( 'To set your password, visit the following address:' ) . "\r\n\r\n"; |
2085 | | $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user->user_login ), 'login' ) . "\r\n\r\n"; |
| 2085 | $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . wp_half_baked_url_encode( $user->user_login ), 'login' ) . "\r\n\r\n"; |
2086 | 2086 | |
2087 | 2087 | $message .= wp_login_url() . "\r\n"; |
2088 | 2088 | |
diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php
index c4c44a0c69..3a9c04ca54 100644
a
|
b
|
function retrieve_password( $user_login = null ) { |
2771 | 2771 | $message .= sprintf( __( 'Username: %s' ), $user_login ) . "\r\n\r\n"; |
2772 | 2772 | $message .= __( 'If this was a mistake, ignore this email and nothing will happen.' ) . "\r\n\r\n"; |
2773 | 2773 | $message .= __( 'To reset your password, visit the following address:' ) . "\r\n\r\n"; |
2774 | | $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), 'login' ) . "\r\n\r\n"; |
| 2774 | $message .= network_site_url( "wp-login.php?action=rp&key=$key&login=" . wp_half_baked_url_encode( $user_login ), 'login' ) . "\r\n\r\n"; |
2775 | 2775 | |
2776 | 2776 | if ( ! is_user_logged_in() ) { |
2777 | 2777 | $requester_ip = $_SERVER['REMOTE_ADDR']; |
diff --git a/tests/phpunit/tests/functions/wpHalfBakedUrlEncode.php b/tests/phpunit/tests/functions/wpHalfBakedUrlEncode.php
new file mode 100644
index 0000000000..cb9880a0ef
-
|
+
|
|
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Tests for wp_half_baked_url_encode() |
| 5 | * |
| 6 | * @ticket 42957 |
| 7 | * |
| 8 | * @group functions.php |
| 9 | * @covers ::wp_half_baked_url_encode |
| 10 | */ |
| 11 | class Tests_Functions_WpHalfBakedUrlEncode extends WP_UnitTestCase { |
| 12 | |
| 13 | public function _data_wp_half_baked_url_encode() { |
| 14 | return array( |
| 15 | array( '', '' ), |
| 16 | array( '.', '%2E' ), |
| 17 | array( '..', '.%2E' ), |
| 18 | array( '...', '..%2E' ), |
| 19 | array( 'Ending period.', 'Ending%20period%2E' ), |
| 20 | array( 'Middle.period', 'Middle.period' ), |
| 21 | array( 'No period', 'No%20period' ), |
| 22 | array( 'Two.periods.', 'Two.periods%2E' ), |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @dataProvider _data_wp_half_baked_url_encode |
| 28 | * |
| 29 | * @param $input_url |
| 30 | * @param $expected |
| 31 | */ |
| 32 | public function test_size_format( $input_url, $expected ) { |
| 33 | $this->assertSame( $expected, wp_half_baked_url_encode( $input_url ) ); |
| 34 | } |
| 35 | } |