From b1a802c475c39e2695fffce93dec53d65192a3a4 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Sun, 1 Nov 2026 16:08:57 +0600 Subject: [PATCH 1/3] Tests: Cover rawurlencode_deep() and urldecode_deep(). See #65819. Props devmuhib009. --- .../tests/formatting/urlencodeDeep.php | 100 ++++++++++++++---- 1 file changed, 77 insertions(+), 23 deletions(-) diff --git a/tests/phpunit/tests/formatting/urlencodeDeep.php b/tests/phpunit/tests/formatting/urlencodeDeep.php index 7783f3a002b05..eb32b9ccfdd5e 100644 --- a/tests/phpunit/tests/formatting/urlencodeDeep.php +++ b/tests/phpunit/tests/formatting/urlencodeDeep.php @@ -1,47 +1,101 @@ assertSame( $expected, urlencode_deep( $input ) ); + public function test_rawurlencode_deep_string() { + $this->assertSame( 'foo%20bar%26baz%3D1', rawurlencode_deep( 'foo bar&baz=1' ) ); } /** - * Data provider. + * Tests that rawurlencode_deep() recursively encodes an array of strings. + * + * @ticket 65819 */ - public static function data_urlencode_deep() { - return array( - array( 'qwerty123456', 'qwerty123456' ), - array( '|!"£$%&/()=?', '%7C%21%22%C2%A3%24%25%26%2F%28%29%3D%3F' ), - array( '^é*ç°§;:_-.,', '%5E%C3%A9%2A%C3%A7%C2%B0%C2%A7%3B%3A_-.%2C' ), - array( 'abc123 @#[]€', 'abc123+%40%23%5B%5D%E2%82%AC' ), - array( 'abc123 @#[]€', urlencode( 'abc123 @#[]€' ) ), + public function test_rawurlencode_deep_array() { + $input = array( + 'foo bar', + 'nested' => array( + 'key space' => 'val space', + ), ); + $expected = array( + 'foo%20bar', + 'nested' => array( + 'key space' => 'val%20space', + ), + ); + + $this->assertSame( $expected, rawurlencode_deep( $input ) ); + } + + /** + * Tests that rawurlencode_deep() encodes object properties. + * + * @ticket 65819 + */ + public function test_rawurlencode_deep_object() { + $input = (object) array( 'prop' => 'hello world' ); + $expected = (object) array( 'prop' => 'hello%20world' ); + + // Use assertEquals to compare object properties by value. + $this->assertEquals( $expected, rawurlencode_deep( $input ) ); + } + + /** + * Tests that urldecode_deep() decodes a single string. + * + * @ticket 65819 + */ + public function test_urldecode_deep_string() { + $this->assertSame( 'foo bar&baz=1', urldecode_deep( 'foo+bar%26baz%3D1' ) ); + $this->assertSame( 'foo bar', urldecode_deep( 'foo%20bar' ) ); } /** - * Tests the whole array as input. + * Tests that urldecode_deep() recursively decodes an array of strings. + * + * @ticket 65819 */ - public function test_urlencode_deep_should_encode_all_values_in_array() { - $data = $this->data_urlencode_deep(); + public function test_urldecode_deep_array() { + $input = array( + 'foo+bar', + 'nested' => array( + 'key space' => 'val%20space', + ), + ); + $expected = array( + 'foo bar', + 'nested' => array( + 'key space' => 'val space', + ), + ); + + $this->assertSame( $expected, urldecode_deep( $input ) ); + } - $actual = wp_list_pluck( $data, 0 ); - $expected = wp_list_pluck( $data, 1 ); + /** + * Tests that urldecode_deep() decodes object properties. + * + * @ticket 65819 + */ + public function test_urldecode_deep_object() { + $input = (object) array( 'prop' => 'hello+world' ); + $expected = (object) array( 'prop' => 'hello world' ); - $this->assertSame( $expected, urlencode_deep( $actual ) ); + // Use assertEquals to compare object properties by value. + $this->assertEquals( $expected, urldecode_deep( $input ) ); } } From c31b7efeec7cb324eebee62dd77ae2f260b2e139 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Mon, 2 Nov 2026 15:21:27 +0600 Subject: [PATCH 2/3] Tests: Preserve urlencode_deep() tests while adding rawurlencode_deep() and urldecode_deep() coverage. --- .../tests/formatting/urlencodeDeep.php | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/formatting/urlencodeDeep.php b/tests/phpunit/tests/formatting/urlencodeDeep.php index eb32b9ccfdd5e..1a3cac667f967 100644 --- a/tests/phpunit/tests/formatting/urlencodeDeep.php +++ b/tests/phpunit/tests/formatting/urlencodeDeep.php @@ -1,15 +1,54 @@ assertSame( $expected, urlencode_deep( $input ) ); + } + + /** + * Data provider. + */ + public static function data_urlencode_deep() { + return array( + array( 'qwerty123456', 'qwerty123456' ), + array( '|!"£$%&/()=?', '%7C%21%22%C2%A3%24%25%26%2F%28%29%3D%3F' ), + array( '^é*ç°§;:_-.,', '%5E%C3%A9%2A%C3%A7%C2%B0%C2%A7%3B%3A_-.%2C' ), + array( 'abc123 @#[]€', 'abc123+%40%23%5B%5D%E2%82%AC' ), + array( 'abc123 @#[]€', urlencode( 'abc123 @#[]€' ) ), + ); + } + + /** + * Tests the whole array as input. + */ + public function test_urlencode_deep_should_encode_all_values_in_array() { + $data = $this->data_urlencode_deep(); + + $actual = wp_list_pluck( $data, 0 ); + $expected = wp_list_pluck( $data, 1 ); + + $this->assertSame( $expected, urlencode_deep( $actual ) ); + } + /** * Tests that rawurlencode_deep() encodes a single string. * From ef6b644bc3e1de3266376e54d0e6ee9abf00b701 Mon Sep 17 00:00:00 2001 From: Muhibul Haque Date: Tue, 3 Nov 2026 10:58:34 +0600 Subject: [PATCH 3/3] Tests: Keep focused string tests for rawurlencode_deep and urldecode_deep. See #65819. Props devmuhib009. --- .../tests/formatting/urlencodeDeep.php | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/tests/phpunit/tests/formatting/urlencodeDeep.php b/tests/phpunit/tests/formatting/urlencodeDeep.php index 1a3cac667f967..5d64f3554a583 100644 --- a/tests/phpunit/tests/formatting/urlencodeDeep.php +++ b/tests/phpunit/tests/formatting/urlencodeDeep.php @@ -58,41 +58,6 @@ public function test_rawurlencode_deep_string() { $this->assertSame( 'foo%20bar%26baz%3D1', rawurlencode_deep( 'foo bar&baz=1' ) ); } - /** - * Tests that rawurlencode_deep() recursively encodes an array of strings. - * - * @ticket 65819 - */ - public function test_rawurlencode_deep_array() { - $input = array( - 'foo bar', - 'nested' => array( - 'key space' => 'val space', - ), - ); - $expected = array( - 'foo%20bar', - 'nested' => array( - 'key space' => 'val%20space', - ), - ); - - $this->assertSame( $expected, rawurlencode_deep( $input ) ); - } - - /** - * Tests that rawurlencode_deep() encodes object properties. - * - * @ticket 65819 - */ - public function test_rawurlencode_deep_object() { - $input = (object) array( 'prop' => 'hello world' ); - $expected = (object) array( 'prop' => 'hello%20world' ); - - // Use assertEquals to compare object properties by value. - $this->assertEquals( $expected, rawurlencode_deep( $input ) ); - } - /** * Tests that urldecode_deep() decodes a single string. * @@ -102,39 +67,4 @@ public function test_urldecode_deep_string() { $this->assertSame( 'foo bar&baz=1', urldecode_deep( 'foo+bar%26baz%3D1' ) ); $this->assertSame( 'foo bar', urldecode_deep( 'foo%20bar' ) ); } - - /** - * Tests that urldecode_deep() recursively decodes an array of strings. - * - * @ticket 65819 - */ - public function test_urldecode_deep_array() { - $input = array( - 'foo+bar', - 'nested' => array( - 'key space' => 'val%20space', - ), - ); - $expected = array( - 'foo bar', - 'nested' => array( - 'key space' => 'val space', - ), - ); - - $this->assertSame( $expected, urldecode_deep( $input ) ); - } - - /** - * Tests that urldecode_deep() decodes object properties. - * - * @ticket 65819 - */ - public function test_urldecode_deep_object() { - $input = (object) array( 'prop' => 'hello+world' ); - $expected = (object) array( 'prop' => 'hello world' ); - - // Use assertEquals to compare object properties by value. - $this->assertEquals( $expected, urldecode_deep( $input ) ); - } }