r89291 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89290‎ | r89291 | r89292 >
Date:21:22, 1 June 2011
Author:platonides
Status:ok
Tags:
Comment:
Document r89248,r89249 isQueryStringBad()
Modified paths:
  • /trunk/phase3/includes/WebRequest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/WebRequest.php
@@ -877,6 +877,8 @@
878878 * Check for a bad query string, which IE 6 will use as a potentially
879879 * insecure cache file extension. See bug 28235. Returns true if the
880880 * request should be disallowed.
 881+ *
 882+ * @return Boolean
881883 */
882884 public function isQueryStringBad() {
883885 if ( !isset( $_SERVER['QUERY_STRING'] ) ) {
@@ -885,9 +887,17 @@
886888
887889 $extension = self::findIE6Extension( $_SERVER['QUERY_STRING'] );
888890 if ( strval( $extension ) === '' ) {
 891+ /* No extension or empty extension (false/'') */
889892 return false;
890893 }
891894
 895+ /* Only consider the extension understood by IE to be potentially
 896+ * dangerous if it is made of normal characters (so it is more
 897+ * likely to be registered with an application)
 898+ * Compromise with api.php convenience. Considers for instance
 899+ * that no sane application will register a dangerous file type
 900+ * in an extension containing an ampersand.
 901+ */
892902 return (bool)preg_match( '/^[a-zA-Z0-9_-]+$/', $extension );
893903 }
894904

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89248* Only blacklist query string extensions which match /^[a-zA-Z0-9_-]+$/. This...tstarling02:01, 1 June 2011
r89249Fix for r89248: don't run the regex if findIE6Extension returns false. Only a...tstarling02:05, 1 June 2011

Status & tagging log