WordPress.org

Make WordPress Core

Changeset 35370


Ignore:
Timestamp:
10/23/2015 05:56:25 AM (5 years ago)
Author:
dd32
Message:

Use wp_parse_url() in esc_url() to avoid parsing bugs in < PHP 5.4.7.

Props johnbillion for unit tests
See #34408
Fixes #34202

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r35314 r35370  
    33993399    if ( ( false !== strpos( $url, '[' ) ) || ( false !== strpos( $url, ']' ) ) ) {
    34003400
    3401         $parsed = parse_url( $url );
     3401        $parsed = wp_parse_url( $url );
    34023402        $front  = '';
    34033403
  • trunk/tests/phpunit/tests/formatting/EscUrl.php

    r34920 r35370  
    211211    }
    212212
     213    /**
     214     * @ticket 34202
     215     */
     216    function test_ipv6_hosts() {
     217        $this->assertEquals( '//[::127.0.0.1]', esc_url( '//[::127.0.0.1]' ) );
     218        $this->assertEquals( 'http://[::FFFF::127.0.0.1]', esc_url( 'http://[::FFFF::127.0.0.1]' ) );
     219        $this->assertEquals( 'http://[::127.0.0.1]', esc_url( 'http://[::127.0.0.1]' ) );
     220        $this->assertEquals( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]', esc_url( 'http://[::DEAD:BEEF:DEAD:BEEF:DEAD:BEEF:DEAD:BEEF]' ) );
     221
     222        // IPv6 with square brackets in the query? Why not.
     223        $this->assertEquals( '//[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( '//[::FFFF::127.0.0.1]/?foo[bar]=baz' ) );
     224        $this->assertEquals( 'http://[::FFFF::127.0.0.1]/?foo%5Bbar%5D=baz', esc_url( 'http://[::FFFF::127.0.0.1]/?foo[bar]=baz' ) );
     225    }
     226
    213227}
Note: See TracChangeset for help on using the changeset viewer.