WordPress.org

Make WordPress Core

Ticket #38070: 38070.patch

File 38070.patch, 1.2 KB (added by cklosows, 3 years ago)

Applies a restriction to avoid the query string, and a unit test.

  • src/wp-includes/class-http.php

     
    359359                }
    360360
    361361                // Work around a bug in Requests when the path starts with // See https://github.com/rmccue/Requests/issues/231
    362                 $url = preg_replace( '!^(\w+://[^/]+)//(.*)$!i', '$1/$2', $url );
     362                $url = preg_replace( '!^(\w+://[^/?]+)//(.*)$!i', '$1/$2', $url );
    363363
    364364                try {
    365365                        $requests_response = Requests::request( $url, $headers, $data, $type, $options );
  • tests/phpunit/tests/http/base.php

     
    389389                $this->assertNotWPError( $res );
    390390        }
    391391
     392        /**
     393         * @ticket 37733
     394         */
     395        function test_url_with_double_slashes_query() {
     396                $url = 'https://wordpress.org?url=http://example.org';
    392397
     398                $res = wp_remote_request( $url );
     399                $this->assertNotWPError( $res );
     400
     401                $response = $res['http_response']->get_response_object();
     402                $this->assertContains( '?url=http://example.org', $response->url );
     403        }
     404
    393405}