Validates wgArticlePath does start with slash (/).
authorJuneHyeon Bae <devunt@gmail.com>
Sat, 24 May 2014 10:48:02 +0000 (19:48 +0900)
committerBrian Wolff <bawolff+wn@gmail.com>
Tue, 10 Nov 2015 22:59:20 +0000 (17:59 -0500)
When relative URL used in $wgArticlePath, and $wgArticlePath does not
start with slash (/), raise FatalError.

Bug: T48998
Change-Id: Ic7cd6f774cff97081f4f35af351161170b4b26eb

includes/Setup.php

index ce091f1..d826b87 100644 (file)
@@ -516,6 +516,21 @@ MWExceptionHandler::installHandler();
 
 require_once "$IP/includes/compat/normal/UtfNormalUtil.php";
 
+
+$ps_validation = Profiler::instance()->scopedProfileIn( $fname . '-validation' );
+
+// T48998: Bail out early if $wgArticlePath is non-absolute
+if ( !preg_match( '/^https?:\/\/|\//', $wgArticlePath ) ) {
+       throw new FatalError(
+               'If you use a relative URL on $wgArticlePath, it must start ' .
+               'with a slash (/).<br><br>See ' .
+               '<a href="https://www.mediawiki.org/wiki/Manual:$wgArticlePath">' .
+               'https://www.mediawiki.org/wiki/Manual:$wgArticlePath</a>'
+       );
+}
+
+Profiler::instance()->scopedProfileOut( $ps_validation );
+
 $ps_default2 = Profiler::instance()->scopedProfileIn( $fname . '-defaults2' );
 
 if ( $wgCanonicalServer === false ) {