Commit graph

93 commits

Author SHA1 Message Date
Bryan Tong Minh
9fb510f31d (bug 26995) File size is now checked before uploading in HTML5 browsers
* Exposed $wgMaxUploadSize to JS
* Exposed message largefileserver to JS
2011-03-04 15:38:37 +00:00
Sam Reed
c07330264d Tweak documentation
Fix constant use in UploadTest
2011-02-27 21:11:45 +00:00
Tim Starling
0a21e2de12 * (bug 24230) Added JAR detection. ZIP archives containing a .class file will be rejected by default. Malformed ZIP archives will be rejected due to the danger of ambiguous parsing on the client side.
* Removed the ZIP subtypes from $wgMimeTypeBlacklist, they no longer need to be there.
* Added ZipDirectoryReader. Added some small ZIP files which are used to test its various error cases. Most were constructed with a hex editor.
* Fixed getStatusArray() to return a consistent type regardless of whether the error message has parameters. This allows error messages with no parameters to work with the Status object conversion code in UploadBase::verifyFile().
2011-02-25 04:51:17 +00:00
Sam Reed
baf83f74b8 More explicit variable definitions, function documentation 2011-02-20 13:33:42 +00:00
Mark A. Hershberger
ec4dbd13cd Bug #26059 — Add support for KML/KMZ filetype
Patch from Derk-Jan Hartman of which he writes:

    I figured adding kml support would be a breeze, but I had not
    counted on the brain dead browser that is IE6.

    Unfortunately, kml contains the element <heading, which triggers
    the protection in detectScript() that protects from uploads that
    IE6 might mistake for HTML.  It triggers on "<head" not sure if we
    can work around this, but Tim will know.
2011-02-19 03:22:03 +00:00
Sam Reed
fa64025161 More parameter documentation 2011-02-19 00:30:18 +00:00
Sam Reed
2c6e16e5e5 Remove unused variables 2011-02-18 01:10:38 +00:00
Sam Reed
bdb325cb4e Fixup some trailing newlines
Fixup indentation of a few methods

Add a couple of return type hints
2011-02-02 10:42:17 +00:00
Platonides
56eee48fcf Remove empty statement (r80993) and unused global (r80766). 2011-01-28 17:34:37 +00:00
Bryan Tong Minh
659af36f3a (bug 26285) Extensions will be automatically generated on upload if the user specified a filename without extension.
Note that this still will throw a warning.
2011-01-27 21:15:50 +00:00
Bryan Tong Minh
9fff147a37 Make the UploadStash repo specific by creating FileRepo::getUploadStash(). In practice this will probably not be used and makes getting an UploadStash object slightly more type work, but I think it is cleaner to have an upload stash explicitly bound to a repo. 2011-01-25 21:26:53 +00:00
Bryan Tong Minh
956b6518cf (bug 26809) Uploading files with multiple extensions where one of the extensions is blacklisted now gives the proper extension in the error message. 2011-01-22 20:33:25 +00:00
Ilmari Karonen
8529441699 Add extension and MIME type as parameters to filetype-mime-mismatch message. Also fix an ungrammatical Finnish translation of filetype-badmime while I'm at it. 2011-01-22 00:12:21 +00:00
Ilmari Karonen
73d5fd73a2 Check that the MIME type is allowed before checking that it matches the extension, and skip the latter check entirely if there is no extension so that the right message (filetype-missing) will be given instead of filetype-mime-mismatch. 2011-01-21 23:35:58 +00:00
Daniel Friesen
39ab3cfc9f Implement Message::isBlank and Message::isDisabled.
And while we're at it... update a random assortment of code using wfEmptyMsg to use the new wfMessage class and our exists/isBlank/isDisabled methods.
2011-01-14 10:51:05 +00:00
Bryan Tong Minh
db544af120 $wgMaxUploadSize may now be set to an array to specify the upload size limit per upload type.
Backwards compatible, if not set to an array, applies to all uploads. If set to an array, per upload type maximums can be set, using the file and url keys. If the * key is set this value will be used as maximum for non-specified types.
2011-01-06 19:42:55 +00:00
Sam Reed
7444a29725 Fixup FIXME on r65818 2011-01-06 03:27:01 +00:00
Benjamin Lees
89bc577c5a Follow-up to r77956: instead of making $wgFileExtensions override $wgFileBlacklist, make sure the upload page does not mark blacklisted extensions as "Permitted file types". I've updated the MediaWiki.org pages to explain how to remove items from the blacklist. 2010-12-12 23:19:24 +00:00
Benjamin Lees
cf2611371d (bug 18372) $wgFileExtensions will now override $wgFileBlacklist 2010-12-07 03:21:00 +00:00
Sam Reed
e76775e06f More unused variables 2010-11-30 18:44:50 +00:00
Sam Reed
c15c1c6abb More reversion of r77297, 2 of 2 commits to keep it readable in CR (hopefully) 2010-11-25 22:24:28 +00:00
Antoine Musso
6fe29c9c30 revert r76464
* mixed style changes and variable removing
* logic changes
* useful comments removed
2010-11-25 20:01:34 +00:00
Roan Kattouw
c31d81ceff Followup r76782: is_a() -> instanceof (we dropped PHP 4 support over 3 years ago), or -> || 2010-11-16 14:23:34 +00:00
Neil Kandalgaonkar
7227b5ab3e fixed typo 2010-11-16 07:09:46 +00:00
Neil Kandalgaonkar
59339ca723 Fixed bug#25784 (thumbnails of stashed files had wrong description URLs).
This fixes the more general problem that the imageinfo returned with stashed uploads was inaccurate, since it was relying on
code that only worked with non-stashed files.

So, I had to:
- move the ApiQueryStashImageInfo module into core. Which others had asked for anyway, and was anticipated sometime later.
  - add lines to AutoLoader and ApiQuery to accomodate the new module

- add an ugly if/then to UploadBase -- based on the type of uploaded file, it will use a different API module to simulate a getImageInfo call. 
  I left a TODO that this situation wasn't ideal, but the way things are now, imageInfo is constructed by the API modules, when it should probably
  really be the File modules. Then the API can wrap that info into various formats.

- add a few new lines to the tests to check imageinfo information in both regular and stashed upload files
2010-11-16 06:57:46 +00:00
Sam Reed
6706fcb62a Fixed up some doxygen warnings 2010-11-13 00:32:54 +00:00
Sam Reed
10ecfeb03b Various unused variables, add some braces
Explicitally define some variables used in hook type calls
2010-11-10 19:49:04 +00:00
Bryan Tong Minh
497dba23b2 Undeprecate UploadForm:BeforeProcessing. Instead only deprecate the code path that would return the user a blank form with no error message. 2010-11-08 21:07:10 +00:00
Neil Kandalgaonkar
902995cb1d core changes for UploadWizard (merged from r73549 to HEAD in branches/uploadwizard/phase3) 2010-11-03 04:32:41 +00:00
Tim Starling
db643f03c2 Fixes for r72024:
* Renamed MediaHandler::verifyFileHook() to verifyUpload() since it isn't a hook and the fact that it operates on files is obvious.
* Separated some concerns by simply passing verifyUpload() function a file path instead of an UploadBase object and MIME type. This simplifies the implementation of subclasses, makes the function accessible to non-UploadBase callers, and avoids breaking the interface constantly due to UploadBase changes.
* Have verifyUpload() return a Status object instead of allowing the idiosyncratic and feature-poor error array convention from UploadBase to infect MediaHandler.

The required update to PagedTiffHandler will be in a subsequent commit.
2010-09-07 10:38:19 +00:00
Alexandre Emsenhuber
c9790ba8e8 Fixed some doxygen warnings 2010-09-04 15:08:02 +00:00
Chad Horohoe
64b2909635 Call time pass-by-ref 2010-09-01 17:15:25 +00:00
Daniel Kinzler
28d16923a1 introducing Generic::verifyFileHook() to let media handlers do the verification on upload. triggered from UploadBase:verifyFile, like the UploadVerifyFile hook. 2010-08-31 14:08:45 +00:00
Daniel Kinzler
1917b3b1bd Follow-up to r71944: Interoducing MimeMagic::improveTypeFromExtension() for two reasons:
a) avoid redundant inspection of file contents when validating uploads, caused by multiple calls to guessMimeType
b) deprecated obscure use of the file extension when guessing mime types, using an explicit call to improveTypeFromExtension() instead

Note that File::getPropsFromPath() will now return an additional field: $props['file-mime'] contains the mime type as determined solely from the file's content, $props['mime'] contains the type that was derived considering the file extension too.
2010-08-31 13:47:24 +00:00
Daniel Kinzler
789baad057 reverting r71944 as per TheDJ's comment. Will investigate a better way to avoid redundant mime guesses 2010-08-31 09:38:11 +00:00
Daniel Kinzler
03a47120bd as per r71789: don't guess mime type again, that's expensive. Re-use the value from FileProps. 2010-08-30 12:51:44 +00:00
Daniel Kinzler
a1130bb205 interoduced new hoop in Uploadbase::verifyFile, as per comments to r71789 2010-08-30 12:10:02 +00:00
Bryan Tong Minh
9e63cdf976 Uploading to a protected title will allow the user to choose a new name instead of showing an error page
* Made validateNameAndOverwrite protected and moved it to validateName since overwriting is now checked in verifyPermissions()
* Fixed mime verification in case getTitle was not yet called
* Checking for overwrites no longer uses $wgUser
	
Other changes:
* convertVerifyErrorToStatus now works
* Allow passing the session key to stashSession in UploadFromStash as well
2010-07-29 13:04:34 +00:00
Bryan Tong Minh
796933d11f Restructured upload-by-url:
* In ApiUpload: moved stuff that is checking instead of actual uploading out of performUpload method
* Made UploadFromUrl conform to standards: 
** In initialize* do only initialization, no actual work
** Moved file fetching to fetchFile
** Consistent use of tempnam()
** Perform the uploading in performUpload, don't define our own doUpload method
* Moved almost all job magic to the UploadFromUrlJob class. This way the job is almost a regular client, and we don't need many special cases to deal with async uploading. 
* Made leaving a message optional; results will be stored in the session otherwise

I did not actually test the async uploading, because I first wanted to commit a properly working synchronous upload-by-url system.
2010-07-28 17:14:51 +00:00
Bryan Tong Minh
546a55a79d (bug 23380) Uploaded files that are larger than allowed by PHP now show a useful error message.
Introduced a WebRequestUpload class which is a wrapper around $_FILES and contains all getUpload* and getFile* methods. This has as advantage that the upload can be passed along without $wgRequest. Also because I like objects.
2010-07-27 20:38:36 +00:00
Sam Reed
8b8500c121 More self:: to $this-> 2010-07-25 18:13:56 +00:00
Platonides
b608000544 Bug 23699: Add trailing \n at the end of <div>s in wrapWikiMsg()
Patch by Umherirrender
2010-05-28 21:22:45 +00:00
Bryan Tong Minh
e693b7c405 Fix for r65818: the proper permission is 'createpage', not 'create'. Skip checking 'createpage' in isAllowed, because a user could have permission to reupload but not to upload. 2010-05-04 14:48:56 +00:00
Bryan Tong Minh
852715397c Fix for r65818. 2010-05-02 20:53:18 +00:00
Bryan Tong Minh
3e394b5bdc (bug 18408) All required permissions for uploading (upload, edit, create) are now checked when loading Special:Upload. Toolbar link for Special:Upload is no longer shown if the user does not have the required permissions.
Found out that UploadBase::isAllowed is a totally inappropriate name for what it is returning. That should perhaps be changed before 1.16 is released.
2010-05-02 20:34:16 +00:00
Mark A. Hershberger
356e9a4bca re: r65152 fix translatewiki problems
* Recover lost $permErrorsUpload in uploadBase::verifyPermissions
* Use Http::isValidURI() to replace UploadFromUrl::isvalidurl()
2010-04-17 16:36:48 +00:00
Mark A. Hershberger
9c7a7e57f0 * New UploadFromUrlJob class to handle Upload-by-Copy
* Define variable for ApiUserrights.php that wasn't defined before.
* Add convertVerifyErrorToStatus and getVerificationErrorCode to
  UploadBase to translate error consts since UploadFromUrl will
  need a message to display to end-users.
* refactor mime-checking out of UploadBase::verifyFile into
  UploadBase::verifyMimeType
* Make UploadBase::verifyFile always return arrays for errors
* Use HttpFunctions instead of custom curl handler for async downloading
* TODO: Need a way to feed errors back to the requestor
* TODO: Need to add watchlist param handling and warnings checks.
2010-04-17 02:43:13 +00:00
Bryan Tong Minh
7a92e75a9f (bug 17941) $wgMaxUploadSize is now honored by all upload sources 2010-04-15 09:28:33 +00:00
Alexandre Emsenhuber
50fb614a08 Fix documentation introduced in r64403 2010-04-12 20:38:30 +00:00
Mark A. Hershberger
234f54a88e * Set $titleObj to null by default on getWatchlistValue since it often isn't needed & check that it is set when it is needed. (follow up r64197).
* Refactoring ApiUpload & UploadBase to make it easier to extend & read.
* Use a class constant for the upload session key instead of a hard-coded-across-several-files value.
* Add UploadBase::appendToUploadFile() method to enable protocols that do incremental upload.
2010-03-30 19:10:10 +00:00