Make WordPress Core

Ticket #23605: 23605.diff

File 23605.diff, 1.8 KB (added by enshrined, 9 years ago)

Escape spaces in esc_url rather than remove them

  • src/wp-includes/formatting.php

     
    32743274
    32753275        if ( '' == $url )
    32763276                return $url;
     3277        $url = str_replace(' ', '%20', $url);
    32773278        $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
    32783279        if ( 0 !== stripos( $url, 'mailto:' ) ) {
    32793280                $strip = array('%0d', '%0a', '%0D', '%0A');
    32803281                $url = _deep_replace($strip, $url);
    32813282        }
     3283
    32823284        $url = str_replace(';//', '://', $url);
    32833285        /* If the URL doesn't appear to contain a scheme, we
    32843286         * presume it needs http:// appended (unless a relative
  • tests/phpunit/tests/formatting/EscUrl.php

     
    55 */
    66class Tests_Formatting_EscUrl extends WP_UnitTestCase {
    77        function test_spaces() {
    8                 $this->assertEquals('http://example.com/MrWordPress', esc_url('http://example.com/Mr WordPress'));
     8                $this->assertEquals('http://example.com/Mr%20WordPress', esc_url('http://example.com/Mr WordPress'));
    99                $this->assertEquals('http://example.com/Mr%20WordPress', esc_url('http://example.com/Mr%20WordPress'));
    1010        }
    1111
  • tests/phpunit/tests/formatting/GetUrlInContent.php

     
    3434                        ), // multiple links
    3535                        array (
    3636                                'ABC<div><a href="http://example.com/Mr%20WordPress 2">LINK</a> CONTENT </div>',
    37                                 "http://example.com/Mr%20WordPress2"
     37                                "http://example.com/Mr%20WordPress%202"
    3838                        ), // escape link
    3939                );
    4040        }