Last modified: 2013-09-04 11:49:39 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T26923, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 24923 - Uploads fail with !$wgStrictFileExtensions and non-preferred extension
Uploads fail with !$wgStrictFileExtensions and non-preferred extension
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Uploading (Other open bugs)
1.17.x
All All
: Normal normal (vote)
: ---
Assigned To: Trevor Parscal
: patch, testme
: 27128 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-24 17:55 UTC by mackyle
Modified: 2013-09-04 11:49 UTC (History)
11 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
REL1_16 patch (741 bytes, patch)
2010-08-24 17:56 UTC, mackyle
Details
trunk patch (693 bytes, patch)
2010-08-24 17:56 UTC, mackyle
Details

Description mackyle 2010-08-24 17:55:17 UTC
STEPS

1. Set $wgCheckFileExtensions to true (the default is already true).
2. Set $wgStrictFileExtensions to false (the default is true).
3. Make sure $wgFileExtensions is not empty (by default it's not empty)
4. Attempt to upload a file with an extension not in the preferred $wgFileExtensions list (and not blacklisted) such as "foo.xyz" for example.

RESULT

The upload form does not accept any files with extensions other than those in the $wgFileExtensions array.

EXPECTED

When $wgStrictFileExtensions is set to false, all uploads that are not blacklisted should be accepted.

VERSIONS

Affects 1.16 release.  The trunk version also appears to be affected.

Patches are attached for both REL1_16 and trunk.
Comment 1 mackyle 2010-08-24 17:56:26 UTC
Created attachment 7651 [details]
REL1_16 patch
Comment 2 mackyle 2010-08-24 17:56:48 UTC
Created attachment 7652 [details]
trunk patch
Comment 3 Derk-Jan Hartman 2010-08-25 00:03:31 UTC
it works if you disable JS right ? This is because the JS code of the upload page is blocking the upload ?
I believe we have another bug on that issue, but i can't find it right now.
Comment 4 mackyle 2010-08-25 05:26:25 UTC
Yes, upload.js is causing the problem, but it's not getting enough information to do it correctly.
Comment 5 Anders Kaseorg 2011-01-13 22:24:27 UTC
Same problem in MediaWiki 1.16.0.  The patch in comment 1 fixes it for me.
Comment 6 Nahor 2011-01-14 23:39:03 UTC
Comment on attachment 7651 [details]
REL1_16 patch


>+			if( $wgCheckFileExtensions && $wgStrictFileExtensions ) {
>+				global $wgFileExtensions, $wgAjaxUploadInterface;
>+				$vars['wgFileExtensions'] = $wgFileExtensions;
>+			}

if wgFileExtensions is not defined in JavaScript, it prevents the rest from working like pre-filling the "destination filename" field.
You should set wgFileExtensions to NULL when wgCheckFileExtensions or wgStrictFileExtensions are false.
	else {
		$vars['wgFileExtensions'] =  NULL;
	}
Comment 7 Mark A. Hershberger 2011-01-22 03:17:33 UTC
Giving this to Trevor since it involves JS
Comment 8 m.bemmerl 2011-05-20 10:28:36 UTC
The patch works for 1.16.5, just tested.
Comment 9 Sidcom 2011-06-17 11:06:35 UTC
Is this the same bug as #24022 - and therefor fixed in r68848 ?
Comment 10 mackyle 2011-06-17 12:28:15 UTC
Sounds very similar.  r68848 and r68849 probably fix it.  I'll verify and close once 1.17 is released.
Comment 11 Dan Collins 2011-07-16 05:41:02 UTC
*** Bug 27128 has been marked as a duplicate of this bug. ***
Comment 12 Sumana Harihareswara 2011-10-07 19:13:48 UTC
mackyle, did you have time to verify the fix? 1.17.0 is now out.
Comment 13 mackyle 2011-10-08 14:15:20 UTC
Finally I just went ahead and installed a new, separate, fresh installation of 1.17.0.

It's still broken in 1.17.0 (and I've changed the version of this bug to reflect that).

The steps are still the same.  When bringing up the upload file page (with $wgStrictFileExtensions set to false), the page shows:

Preferred file types: png, gif, jpg, jpeg.

Prohibited file types: html, htm, js, jsb, mhtml, mht, xhtml, xht, php, phtml, php3, php4, php5, phps, shtml, jhtml, pl, py, cgi, exe, scr, dll, msi, vbs, bat, com, pif, cmd, vxd, cpl.

I can successfully upload a .png/.jpg file with no problem.

However, attempting to upload a .pdf file (notice it's not in the prohibited list) produces this output:

    ".pdf" is an unwanted file type. Preferred file types are $2.

Please modify the file description below and try again.

Yes, it really shows "$2" instead of an actual list of preferred types -- that's another bug.

Also version 1.17.0 has changed enough that the previously provided patches no longer work to fix the problem and I haven't poked around enough to figure out a new patch for 1.17.0.
Comment 14 mackyle 2011-10-08 14:26:21 UTC
Never mind.  You can just hit the big "Ignore warning and save file anyway" button down at the bottom of the dialog and continue on to save the file.

Marking this resolved in 1.17.0.
Comment 15 joe.fowler 2011-10-12 08:31:38 UTC
Hold on, isn't that just a work-around? Should it not be not producing the message at all?

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links