r30090 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30089‎ | r30090 | r30091 >
Date:00:16, 24 January 2008
Author:brion
Status:old
Tags:
Comment:
MSIE URL safety
Modified paths:
  • /trunk/extensions/BotQuery/query.php (modified) (history)

Diff [purge]

Index: trunk/extensions/BotQuery/query.php
@@ -58,6 +58,29 @@
5959 require_once( "$IP/includes/Setup.php" );
6060 }
6161
 62+// URL safety checks
 63+//
 64+// See RawPage.php for details; summary is that MSIE can override the
 65+// Content-Type if it sees a recognized extension on the URL, such as
 66+// might be appended via PATH_INFO after 'api.php'.
 67+//
 68+// Some data formats can end up containing unfiltered user-provided data
 69+// which will end up triggering HTML detection and execution, hence
 70+// XSS injection and all that entails.
 71+//
 72+// Ensure that all access is through the canonical entry point...
 73+//
 74+if( isset( $_SERVER['SCRIPT_URL'] ) ) {
 75+ $url = $_SERVER['SCRIPT_URL'];
 76+} else {
 77+ $url = $_SERVER['PHP_SELF'];
 78+}
 79+if( !preg_match( '!/query\.php$!', $url ) ) {
 80+ wfHttpError( 403, 'Forbidden',
 81+ 'API must be accessed through the primary script entry point.' );
 82+ return;
 83+}
 84+
6285 wfProfileIn( 'query.php' );
6386
6487 define( 'GN_FUNC', 0 );

Status & tagging log