From ff4f545fc953c45f468c2c71e3489e77b4a53aef Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 1 Nov 2014 00:53:26 +0000 Subject: [PATCH] [28785] introduced a bug, where encoded query arguments were decoded by `parse_str()` inside of `wp_parse_str()` but never re-encoded later on. This encodes them, adds unit test. Props obenland. Fixes #29636. git-svn-id: https://develop.svn.wordpress.org/trunk@30133 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/general-template.php | 1 + tests/phpunit/tests/general/paginateLinks.php | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php index bf710041e6..6ecf8271a6 100644 --- a/src/wp-includes/general-template.php +++ b/src/wp-includes/general-template.php @@ -2475,6 +2475,7 @@ function paginate_links( $args = '' ) { if ( isset( $url_parts[1] ) ) { wp_parse_str( $url_parts[1], $query_args ); + $query_args = urlencode_deep( $query_args ); } $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link ); diff --git a/tests/phpunit/tests/general/paginateLinks.php b/tests/phpunit/tests/general/paginateLinks.php index df8fda1dd4..b2083bbd26 100644 --- a/tests/phpunit/tests/general/paginateLinks.php +++ b/tests/phpunit/tests/general/paginateLinks.php @@ -188,7 +188,10 @@ EXPECTED; } function add_query_arg( $url ) { - return add_query_arg( array( 'foo' => 'bar' ), $url ); + return add_query_arg( array( + 'foo' => 'bar', + 's' => 'search+term', + ), $url ); } /** @@ -208,13 +211,13 @@ EXPECTED; $document = new DOMDocument(); $document->preserveWhiteSpace = false; - // All links should have foo=bar arguments: + // All links should have foo=bar arguments and be escaped: $data = array( - 0 => home_url( '/?foo=bar' ), - 1 => home_url( '/?foo=bar' ), - 3 => home_url( '/?paged=3&foo=bar' ), - 5 => home_url( '/?paged=5&foo=bar' ), - 6 => home_url( '/?paged=3&foo=bar' ), + 0 => home_url( '/?foo=bar&s=search+term' ), + 1 => home_url( '/?foo=bar&s=search+term' ), + 3 => home_url( '/?paged=3&foo=bar&s=search+term' ), + 5 => home_url( '/?paged=5&foo=bar&s=search+term' ), + 6 => home_url( '/?paged=3&foo=bar&s=search+term' ), ); foreach ( $data as $index => $expected_href ) {