Merge "Avoid bogus IE extension check errors in img_auth.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 22 Apr 2014 20:59:04 +0000 (20:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 22 Apr 2014 20:59:04 +0000 (20:59 +0000)
img_auth.php
includes/filebackend/FileBackend.php

index 64086be..a3485df 100644 (file)
@@ -73,7 +73,7 @@ function wfImageAuthMain() {
 
        // Check for bug 28235: QUERY_STRING overriding the correct extension
        $whitelist = array();
-       $extension = FileBackend::extensionFromPath( $path );
+       $extension = FileBackend::extensionFromPath( $path, 'rawcase' );
        if ( $extension != '' ) {
                $whitelist[] = $extension;
        }
index 7156fba..f99da6d 100644 (file)
@@ -1402,12 +1402,20 @@ abstract class FileBackend {
         * Get the final extension from a storage or FS path
         *
         * @param string $path
+        * @param string $case One of (rawcase, uppercase, lowercase) (since 1.24)
         * @return string
         */
-       final public static function extensionFromPath( $path ) {
+       final public static function extensionFromPath( $path, $case = 'lowercase' ) {
                $i = strrpos( $path, '.' );
+               $ext = $i ? substr( $path, $i + 1 ) : '';
 
-               return strtolower( $i ? substr( $path, $i + 1 ) : '' );
+               if ( $case === 'lowercase' ) {
+                       $ext = strtolower( $ext );
+               } elseif ( $case === 'uppercase' ) {
+                       $ext = strtoupper( $ext );
+               }
+
+               return $ext;
        }
 
        /**