Make WordPress Core

Ticket #37733: 37733.diff

File 37733.diff, 1.4 KB (added by flixos90, 8 years ago)
  • src/wp-includes/class-http.php

     
    272272                        return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ) );
    273273                }
    274274
     275                // Fix URLs with double slashes at the start of the path.
     276                if ( ! empty( $arrURL['path'] ) && 0 === strpos( $arrURL['path'], '//' ) ) {
     277                        $new_path = substr( $arrURL['path'], 1 );
     278                        $url = str_replace( $arrURL['path'], $new_path, $url );
     279                        $arrURL['path'] = $new_path;
     280                }
     281
    275282                // If we are streaming to a file but no filename was given drop it in the WP temp dir
    276283                // and pick its name using the basename of the $url
    277284                if ( $r['stream'] ) {
  • tests/phpunit/tests/http/base.php

     
    376376                $this->assertTrue( ! is_wp_error( $res ), print_r( $res, true ) );
    377377        }
    378378
     379        /**
     380         * @ticket 37733
     381         */
     382        function test_url_with_double_slashes_path() {
     383                $url = $this->redirection_script . '?rt=' . 0;
    379384
     385                $path = parse_url( $url, PHP_URL_PATH );
     386                $url = str_replace( $path, '/' . $path, $url );
     387
     388                $res = wp_remote_request( $url );
     389                $this->assertNotWPError( $res );
     390        }
     391
     392
    380393}