When checking whitelist of extensions, only count last extension.
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 9 Mar 2014 09:08:19 +0000 (06:08 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 9 Mar 2014 09:12:04 +0000 (06:12 -0300)
When we are doing blacklisted extensions, we count all extensions
as some programs (like apache sometimes) consider extensions that
aren't the final extension. However when doing whitelists we need
to only count the last extension, otherwise people can name files
foo.goodExt.BadExt. For example [[commons:File:Deamado ko.png.bmp]]

I do not believe this represents a security risk as bad files are
still filtered out. However it does allow unwanted files to be
uploaded.

Bug: 62451
Change-Id: Ie27c15f749812710571f432bc5915e498f8017e3

includes/upload/UploadBase.php

index db7a24e..6cce4ac 100644 (file)
@@ -786,7 +786,7 @@ abstract class UploadBase {
                        return $this->mTitle;
                } elseif ( $blackListedExtensions ||
                                ( $wgCheckFileExtensions && $wgStrictFileExtensions &&
-                                       !$this->checkFileExtensionList( $ext, $wgFileExtensions ) ) ) {
+                                       !$this->checkFileExtension( $this->mFinalExtension, $wgFileExtensions ) ) ) {
                        $this->mBlackListedExtensions = $blackListedExtensions;
                        $this->mTitleError = self::FILETYPE_BADTYPE;
                        $this->mTitle = null;