Avoid bogus IE extension check errors in img_auth.php
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 22 Apr 2014 02:30:44 +0000 (19:30 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 22 Apr 2014 02:30:48 +0000 (19:30 -0700)
Change-Id: I57083d3fe0517b94d3b786970b412e6ec51cf5f0

img_auth.php
includes/filebackend/FileBackend.php

index dc3dcd8..3b8cc91 100644 (file)
@@ -78,7 +78,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;
        }
 
        /**