r94352 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94351‎ | r94352 | r94353 >
Date:14:45, 12 August 2011
Author:catrope
Status:ok
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -516,7 +516,9 @@
517517 wfSuppressWarnings();
518518 $bits = parse_url( $url );
519519 wfRestoreWarnings();
520 - if ( !$bits ) {
 520+ // parse_url() returns an array without scheme for some invalid URLs, e.g.
 521+ // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' )
 522+ if ( !$bits || !isset( $bits['scheme'] ) ) {
521523 return false;
522524 }
523525

Status & tagging log