X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FGlobalFunctions.php;h=c02555337457f6b3faa781cf60e9c291390c542d;hb=3599f29cc3a1ca43c3ae1522e27d77a6e9222d29;hp=0152209d0787409d22560408a8be1ad573c54010;hpb=639a3ac6f268c5a016ad32b7e9b80bb1e652583a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 0152209d07..c025553374 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -811,6 +811,18 @@ function wfParseUrl( $url ) { Wikimedia\suppressWarnings(); $bits = parse_url( $url ); Wikimedia\restoreWarnings(); + + // T212067: PHP < 5.6.28, 7.0.0–7.0.12, and HHVM (all relevant versions) screw up parsing + // the query part of pathless URLs + if ( isset( $bits['host'] ) && strpos( $bits['host'], '?' ) !== false ) { + list( $host, $query ) = explode( '?', $bits['host'], 2 ); + $bits['host'] = $host; + $bits['query'] = $query + . ( $bits['path'] ?? '' ) + . ( isset( $bits['query'] ) ? '?' . $bits['query'] : '' ); + unset( $bits['path'] ); + } + // parse_url() returns an array without scheme for some invalid URLs, e.g. // parse_url("%0Ahttp://example.com") == [ 'host' => '%0Ahttp', 'path' => 'example.com' ] if ( !$bits || !isset( $bits['scheme'] ) ) {