Commit graph

354 commits

Author SHA1 Message Date
umherirrender
957adbef22 Fixed some @params documentation (includes/[file...|upload])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I8804ebe0922d3a414863b162a2110e0b9e49b80f
2014-04-19 17:19:17 +02:00
umherirrender
725d9d125d Removed unneeded spaces and colons in @param and friends
Also swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ic36c8c7820a6c2d603f1138130670c6bf6a1ca59
2014-04-08 16:02:49 +00:00
kaldari
0fb104497c Adding debugging for bug 62241
In the event of a bad filename warning record the relavent variables
so that we can figure out what is causing the failure.

See also change I532f8ee7c7455e43862b0204a7fff23d6792412e

Bug: 62241
Change-Id: If5d8b9e7f34c0f9bd09684d7dada8fafd7f5f7c2
2014-03-31 21:04:43 +00:00
umherirrender
2000672ac3 Fixed spacing
- Added spaces after if/foreach/catch
- Added new line before end of file
- Added or removed spaces before/after parenthesis, comma
- Added spaces around string concat

Change-Id: I0590070f1b3542108e242730e8d9a3ba9831e94f
2014-03-20 20:37:30 +00:00
Brian Wolff
3090ace527 When checking whitelist of extensions, only count last extension.
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
2014-03-09 06:12:04 -03:00
csteipp
7d923a6b53 SECURITY: Disallow non-whitelisted namespaces
Disallow uploading non-whitelisted namespaces. Also disallow iframe
elements.

User will get an error including the namespace name if they use a non-
whitelisted namespace.

Bug: 60771
Change-Id: Id5c022543184b19b77ad32d9a8a0c2dbbc5e9038
2014-02-27 15:06:13 +01:00
jenkins-bot
806df0771e Merge "UploadStash us_props fix for Postgres" 2014-02-21 14:40:14 +00:00
Aaron Schulz
0ef8100a25 UploadStash us_props fix for Postgres
* Follows up c7f4586fe1

Change-Id: I5a8568efaf0817ca743de722d5486457ff1a8d87
2014-02-19 13:28:26 -08:00
Alexandre Emsenhuber
8d701eeeea Remove trailing line breaks from wfDebugLog() messages
This is useless since the message is passed through trim() and a
line break is added afterwards.

Change-Id: I1a26b30a07f7c9c749fce5bb6b2b4b3d79901b7c
2014-02-04 22:16:13 +01:00
jenkins-bot
7af7ba2f05 Merge "Add missing uploadstash.us_props for PostgreSQL" 2014-01-29 18:19:48 +00:00
csteipp
b4260e2daa SECURITY: Return error on invalid XML for SVGs
Return an error from UploadBase::detectScriptInSvg when the svg has
XML that cannot be parsed. Usually the XML is invalid, or the parser has
run out of memory trying to parse the file.

This patch is rebased on top of bug 57550.

Bug: 58553
Change-Id: I32661a27d7417cc2c69b844c805b190d6486d17a
2014-01-13 22:15:27 -08:00
mglaser
5205b03f62 SECURITY: Disallow stylesheets in svg
Bug: 57550
Change-Id: I73d148519c077e628d82a89280faa088bac9bdf5
2014-01-14 02:00:12 +01:00
Brad Jorsch
81486e15ee Do not reveal RevDeled file title
When an file is being uploaded, we tell the user if it has been
uploaded and deleted in the past. But we shouldn't reveal the title
under which that was done if the file was suppressed via RevDel.

Note this introduces a breaking API change: clients may now receive a
"deleted-archive" warning with an empty value if the title was
suppressed.

Bug: 59167
Change-Id: I01a3ac2ba0cbac6b28de26a7f1a1d09b6b02097e
2014-01-03 12:40:26 -05:00
Bartosz Dziewoński
c817809a11 Remove reference to deleted file
It didn't even point to the right location…

Follow-up to I70d20bf2.

Change-Id: I7f909873035b9176ba9b7c2bf41b05d9eede3cc4
2014-01-03 13:01:28 +01:00
umherirrender
073abe3e12 No variable assignment on return statement
Split the variable assignment and the return statement in two lines for
better readability.

When there was two return statements in one method the logic was swapped
to have only one return statement.

Change-Id: Id7a01b4a2df96036435f9e1a9be5678dd124b0af
2014-01-02 09:43:35 +00:00
Bryan Davis
f9c6af781c Fix TempFSFile creation
A new TempFSFile should be instantiated via the factory rather than
using the object constructor.

Change-Id: Icd059566087c6a644a0d0ed69abfe13b88b38ee4
2013-12-13 12:49:45 -07:00
Bryan Davis
e4009c7367 Use TempFSFile in UploadFromUrl
Make it a little harder for the developer to leak files in the temp
directory by managing the temporary file with a TempFSFile instance.

Change-Id: I8bafc3a6e6212781d9e2e4f8f370ce7c446f1fd5
2013-12-12 16:10:14 -07:00
saper
c7f4586fe1 Add missing uploadstash.us_props for PostgreSQL
This field was introduced in e5d41cca90
but only for MySQL.

Change-Id: I057b1dd845a5ab7ae05f5597454981a6e2c12698
2013-12-09 20:46:17 +01:00
jenkins-bot
bdc5103819 Merge "Move closing parenthesis from multi line if and function to own line" 2013-12-02 06:33:48 +00:00
Aaron Schulz
6c5104111c Fixed fatal error when getLocalCopy() fails
bug: 40166
Change-Id: Ibfcddc1a9c05fad4ac0b51a5a046d1ffaeb49db8
2013-12-02 03:19:17 +00:00
umherirrender
0bc583af2c Move closing parenthesis from multi line if and function to own line
The Line continuation Coding conventions prefers the closing parenthesis
on the same line than the beginning curly braces. This is done for ifs
and functions.
Also move some boolean operator from the end of a line to the beginning
and changed some indentation to make the condition hopefully better
readable.

Change-Id: Id0437b06bde86eb5a75bc59eefa19e7edb624426
2013-12-01 21:39:00 +01:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
jenkins-bot
853c6852ec Merge "Rename wfIsHipHop() to wfIsHHVM()" 2013-11-04 18:32:39 +00:00
Siebrand Mazeland
e61cb8218b Update docs and declare visibility on class props
Change-Id: Ib0f02202d075d4a56dc4e37b08d7ac9399e8c86c
2013-11-01 12:35:27 +01:00
Chad Horohoe
22dca6484f Rename wfIsHipHop() to wfIsHHVM()
The former is only really used to refer to the older hphp compiler.
Now all docs pretty much exclusively are referring to HHVM and
that's the project's name going forward.

While we're here, swap HPHP_VERSION for HHVM_VERSION. Either work,
but the latter is more correct.

Only affected extension (in Git or SVN) is GWToolset, fixing in
I3a490ef.

Change-Id: I81e4ce5d14e344e67045050261f91b3c0159f222
2013-10-29 15:36:10 -07:00
Brad Jorsch
d4b250ad38 UploadStash::removeFileNoAuth shouldn't need auth
UploadStash::getFile has a "noAuth" parameter, which should be set true
when this is called from UploadStash::removeFileNoAuth.

Callers should already be doing their own auth checking, or calling
UploadStash::removeFile.

Bug: 56298
Change-Id: Ic70c4e2bc6df5cb9b139a3631766f8ff0ec4ef02
2013-10-29 11:58:17 -04:00
jenkins-bot
591f756dc5 Merge "Add way of including all stderr output when executing command" 2013-09-30 16:03:24 +00:00
Brian Wolff
37e32abb0e Add way of including all stderr output when executing command
This adds an option to wfShellExec (and convenience function
wfShellExecWithStderr), to make sure all stderr is duplicated
to stdout. The previous method of doing this was to include
2>&1 on the command line. However this did not redirect errors
from limit.sh (For example cgroups not set up, or if a command
reached the file size limit set by ulimit).

Not sure if this is the best approach, but it seems to work well,
and compared to most other approaches I considered, actually gets
the ulimit errors redirected too.

Currently some files fail to render with no error whatsoever,
hopefully this patch will make what went wrong more obvious.

Also fix a comment in wfShellExec that was incorrect (trailing \n),
and make the initial value of the return value variable be 200, so
if there's ever a bug in php where its not being set properly, it
would be immediately obvious what is happening.

Bug: 53824
Change-Id: I833aeb3ab9da726ecb97331369ea187daad7e795
2013-09-28 17:48:37 -03:00
Brion Vibber
3cfc7d5df1 Remove duplicate file extensions from output messages
If a file type was added to $wgFileExtensions by both local configuration
and defaults in an extension (eg TimedMediaHandler and LocalSettings.php
both adding 'ogg' and 'ogv') it was being listed twice in the UI messages
listing acceptable types.

Runs array_unique() over the array on various outputs.

Bug: 54378
Change-Id: I14cd098d8b27099f8f803630535f33549740295c
2013-09-27 17:49:21 +00:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
Brian Wolff
3846d10487 Be stricter for file types where we don't know canonical extension
Previously if a file had a format, where we didn't have an
extension associated with it in mime.types, people could upload
it with any extension that is in $wgFileExtensions. This meant
people could upload a non-allowed file type if it had an allowed
extension, and the non-allowed file type didn't have a canonical
extension in mime.types

Bug: 39012
Change-Id: Ib373fafdfceceed65fbd23cf468f3c19196545c9
2013-08-21 17:34:10 +00:00
Brian Wolff
7a0ed924ef Have separate timeouts for upload by url ($wgCopyUpload[Async]Timeout)
Add $wgCopyUploadTimeout and $wgCopyUploadAsyncTimeout to control
the timeout for the http request used to fetch the file during upload
by url. People reasonably may want to make this higher than $wgHTTPTimeout
for the case where very large files are being downloaded.

Also add the ability for callers of UploadFromUrl::fetchFile
to override the timeout as they please (and set any other HTTP opts).

This patch was inspired by conversation with dan-nl about gwtoolset.

Change-Id: Ia85a97434c14adcdaafc0802cbe0530bfa57a435
2013-08-07 21:05:07 +02:00
jenkins-bot
5e5579d04c Merge "Follow-up 4233341283 - Fix behaviour $wgVerifyMimeType = false;" 2013-07-30 08:52:13 +00:00
nischayn22
50ca5a7d17 hook to intercept upload_by_url
This is planned to be used for intercepting by UW for Flickr blacklisting.

Bug: 42307
Change-Id: Ia3daaeba1ce5e69e751ffc2ae5afd5e449cf4aa7
2013-07-24 19:11:33 +02:00
Brian Wolff
337fd7790e Follow-up 4233341283 - Fix behaviour $wgVerifyMimeType = false;
Should probably be backported to stable.

Bug: 49717
Change-Id: If1d6e8fed575bf2816a10db066ec4e023460ee1e
2013-07-06 16:02:19 +00:00
Brad Jorsch
18062eb3b0 Add user rights 'viewmywatchlist', 'editmywatchlist'
These are needed for OAuth grants.

Note that, even if 'editmywatchlist' is not granted, various actions
will still allow for adding but not removing of pages.

Change-Id: Ie33446a228dd6ed0114730935c1bf65667f5ce01
2013-06-26 10:20:40 -04:00
Aaron Schulz
c61d48f87e Stop spamming exception log with random upload stash failures
* Things like authorization and validation problems do not belong in the
  exception log.

Change-Id: I3c4c1bab65cfe9111dc2161bda6d023234112900
2013-06-25 16:10:42 -07:00
csteipp
4233341283 SECURITY: Do checks on all upload types
Also, verify file before stashing it

Change-Id: Ib2474cb778d53959a4f479e53d0392f916b18d83
2013-05-21 13:20:06 -07:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
umherirrender
c6894adefc Fixed spacing
Added spaces around some parenthesis

Change-Id: If1e50e2a7b0046e91c0bbce8bf6641d8b2446a1d
2013-05-09 19:48:10 +02:00
csteipp
ba672550c0 SECURITY: Check SVG xml encoding against whitelist
Some browsers will interpret obscure xml encodings as UTF-8, while
PHP/expat will interpret the given encoding in the xml declaration.

bug: 47304
Change-Id: I3b311a7078d977ae89c51e95e625d79fba183cfc
2013-04-30 13:20:05 -07:00
umherirrender
ee31d37821 Fixed spacing in context/installer/media/templates/upload folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9761be9fa47adc3554852a97b19792b4648466ad
2013-04-21 06:22:06 +00:00
umherirrender
15abcf71ca Added/Removed spaces around string concatenation
And added/removed spaces around some other tokens,
like +, -, *, /, <, >, =, !

Fixed windows newline style

Change-Id: I0b9c8c408f3f6bfc0d685a074d7ec468fb848fc8
2013-04-13 13:36:24 +02:00
Timo Tijhof
acb292d733 phpcs: Fix Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore violations
ERROR: Closing brace must be on a line by itself
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore

- For non-empty scopes it means the closing brace must be on a separate
  line. This is already the case in most classes in some cases the "lazy
  closing" is still used.
  array(
   'x' ); // Moved } to next line
  function () { return 'x'; } // Moved } to next line
  case 1:
    stuff; break; // Moved break to next line
- For empty function it serves as a visual distinction between there not
  being a scope block / function body and there being an empty function
  body.
  function foo(); // No body
  function foo() {} // Empty body - violation
  function bar() { // Empty body corrected
  }

Change-Id: I0310ec379c6d41cc7d483671994d027a49f32164
2013-04-11 07:34:41 +00:00
jenkins-bot
e0f1be027b Merge "Protected function UploadBase->validateName changed to public" 2013-04-05 21:11:08 +00:00
rahul21
ced901634f Protected function UploadBase->validateName changed to public
*Any class that is not part of the UploadBase class 
(so it can't call protected functions or members on an UploadBase object).
If you, for example,build an extension that uses an UploadBase instance,
there is no way to get the title validation error.

Bug: 38221

Change-Id: Ie6c3f95a09ef84777313c3ec2edd31c50c397e28
2013-04-05 21:04:56 +00:00
umherirrender
6c278b6d7e fix some spacing
* Removed spaces around array index
* Removed double spaces or added spaces to begin or end of function
  calls, method signature, conditions or foreachs
* Added braces to one-line ifs
* Changed multi line conditions to one line conditions
* Realigned some arrays

Change-Id: Ia04d2a99d663b07101013c2d53b3b2e872fd9cc3
2013-03-25 22:22:46 +00:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
Aaron Schulz
9671fd3ba6 Fixed E_STRICT warning:
Strict Standards: Declaration of UploadFromChunks::stashFile() should be
compatible with UploadBase::stashFile(User $user = NULL)

Change-Id: If14d7aeacb23df16bff94c5989cde4ee31c1d105
2013-03-15 05:54:08 +00:00