From 0be893412662c8b55e7c688fe679593999516d53 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Fri, 12 Aug 2011 14:45:37 +0000 Subject: [PATCH] Guard against parse_url() returning weird things in wfParseUrl(). This is not a problem in practice unless you mess up your local copy badly enough that it tries to do wfParseUrl("%0Ahttp://example.com") like mine just did, but wfParseUrl() should handle all invalid input gracefully without throwing notices. --- includes/GlobalFunctions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 98a1ea75fc..3c48d72eb3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -516,7 +516,9 @@ function wfParseUrl( $url ) { wfSuppressWarnings(); $bits = parse_url( $url ); wfRestoreWarnings(); - if ( !$bits ) { + // parse_url() returns an array without scheme for some invalid URLs, e.g. + // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' ) + if ( !$bits || !isset( $bits['scheme'] ) ) { return false; } -- 2.20.1