Skip to content

Commit 2b8adf7

Browse files
Tests: Cover esc_url_raw().
Verify that ampersands are not entity-encoded in database context and custom protocols are accepted. Developed in #15360. Props devmuhib, huzaifaalmesbah, lancewillett. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@65733 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1f84b51 commit 2b8adf7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎tests/phpunit/tests/formatting/escUrl.php‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @group formatting
55
*
66
* @covers ::esc_url
7+
* @covers ::esc_url_raw
78
*/
89
class Tests_Formatting_EscUrl extends WP_UnitTestCase {
910

@@ -311,4 +312,15 @@ public function test_ipv6_hosts() {
311312
$this->assertSame( '//[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( '//[::FFFF::127.0.0.1]/?foo[bar]=baz' ) );
312313
$this->assertSame( 'http://[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( 'http://[::FFFF::127.0.0.1]/?foo[bar]=baz' ) );
313314
}
315+
316+
/**
317+
* Tests that esc_url_raw() preserves raw ampersands and accepts custom protocols.
318+
*
319+
* @ticket 65819
320+
*/
321+
public function test_esc_url_raw() {
322+
$url = 'custom://example.com/?one=1&two=2';
323+
324+
$this->assertSame( $url, esc_url_raw( $url, array( 'custom' ) ) );
325+
}
314326
}

0 commit comments

Comments
 (0)