64 if ( isset(
$vars[
'SERVER_SOFTWARE'] )
65 && isset(
$vars[
'REQUEST_URI'] )
66 && self::haveUndecodedRequestUri(
$vars[
'SERVER_SOFTWARE'] ) )
68 $urlPart =
$vars[
'REQUEST_URI'];
69 } elseif ( isset(
$vars[
'QUERY_STRING'] ) ) {
70 $urlPart =
$vars[
'QUERY_STRING'];
75 if ( self::isUrlExtensionBad( $urlPart, $extWhitelist ) ) {
81 if ( isset(
$vars[
'PATH_INFO'] )
82 && self::isUrlExtensionBad(
$vars[
'PATH_INFO'], $extWhitelist ) )
101 if ( strval( $urlPart ) ===
'' ) {
105 $extension = self::findIE6Extension( $urlPart );
106 if ( strval( $extension ) ===
'' ) {
111 if ( in_array( $extension, [
'php',
'php5' ] ) ) {
115 if ( in_array( $extension, $extWhitelist ) ) {
120 if ( !preg_match(
'/^[a-zA-Z0-9_-]+$/', $extension ) ) {
141 $questionPos = strpos( $url,
'?' );
142 if ( $questionPos ===
false ) {
143 $beforeQuery = $url .
'?';
145 } elseif ( $questionPos === strlen( $url ) - 1 ) {
149 $beforeQuery = substr( $url, 0, $questionPos + 1 );
150 $query = substr( $url, $questionPos + 1 );
160 $url = $beforeQuery .
$query;
161 if ( self::isUrlExtensionBad( $url, $extWhitelist ) ) {
194 $hashPos = strpos( $url,
'#' );
195 if ( $hashPos !==
false ) {
196 $urlLength = $hashPos;
198 $urlLength = strlen( $url );
200 $remainingLength = $urlLength;
201 while ( $remainingLength > 0 ) {
203 $pos += strcspn( $url,
'.', $pos, $remainingLength );
204 if ( $pos >= $urlLength ) {
211 $remainingLength = $urlLength - $pos;
215 $nextPos = $pos + strcspn( $url,
"<>\\\"/:|?*.", $pos, $remainingLength );
216 if ( $nextPos >= $urlLength ) {
219 return substr( $url, $pos, $urlLength - $pos );
221 if ( $url[$nextPos] ===
'?' ) {
224 $extension = substr( $url, $pos, $nextPos - $pos );
225 if ( strcasecmp( $extension,
'exe' ) && strcasecmp( $extension,
'dll' ) &&
226 strcasecmp( $extension,
'cgi' ) )
235 $remainingLength = $urlLength - $pos;
259 static $whitelist = [
263 if ( preg_match(
'/^(.*?)($|\/| )/', $serverSoftware, $m ) ) {
264 return in_array( $m[1], $whitelist );
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
static isUrlExtensionBad($urlPart, $extWhitelist=[])
Given a right-hand portion of a URL, determine whether IE would detect a potentially harmful file ext...
static findIE6Extension($url)
Determine what extension IE6 will infer from a certain query string.
static haveUndecodedRequestUri($serverSoftware)
When passed the value of $_SERVER['SERVER_SOFTWARE'], this function returns true if that server is kn...
static areServerVarsBad($vars, $extWhitelist=[])
Check a subset of $_SERVER (or the whole of $_SERVER if you like) to see if it indicates that the req...
Internet Explorer derives a cache filename from a URL, and then in certain circumstances, uses the extension of the resulting file to determine the content type of the data, ignoring the Content-Type header.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static configuration should be added through ResourceLoaderGetConfigVars instead & $vars
static fixUrlForIE6($url, $extWhitelist=[])
Returns a variant of $url which will pass isUrlExtensionBad() but has the same GET parameters...