Commit graph

369 commits

Author SHA1 Message Date
Chad Horohoe
35e1c7cd67 Don't rely on $wgTitle in WebRequest
All callers have been updated to provide their own getLocalUrl() calls as
appropriate, so deprecate calling appendQueryValue() and appendQueryArray()
with $onlyquery = false.

appendQuery() is now unused and deprecated as it always assumed $onlyquery = false

Change-Id: I142195c39f278165118a52143031008d9c68e01a
2014-09-24 13:49:38 -07:00
Bryan Davis
e2fb163be2 Use protocol default port with HTTP_X_FORWARDED_PROTO
When $_SERVER['HTTP_X_FORWARDED_PROTO'] is set, keep the detected
protocol default port rather than using the local server port when
creating a canonical URL.

Bug: 70021
Change-Id: I2b37da5872929e1c461ff20cccf3dfe11f182a2f
2014-08-25 21:54:41 -06:00
withoutaname
b74a36fce6 Documentation: Remove paragraph about not creating a 2nd WebRequest
WebRequest is no longer required to be a singleton for $wgRequest,
thanks to https://gerrit.wikimedia.org/r/144996

Change-Id: Ica629fd28d96f8ee77ee548b0a284abf24b1e780
2014-07-26 19:27:36 -07:00
umherirrender
1c68a1ee86 Cleanup some docs (includes/*.php)
- Swap "$variable type" to "type $variable"
- Added missing types
- Fixed spacing inside docs
- Makes beginning of @param/@return/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: I783e4dbfe5f6f98b32b9a03ccf6439e13e132bcc
2014-07-24 19:42:24 +02:00
Chad Horohoe
5a4a33a8ff Remove support for magic_quotes_gpc
This "feature" of PHP has been disabled by default for quite some
time, deprecated in 5.3 and removed entirely in 5.4.

See <http://www.php.net/manual/en/security.magicquotes.php> for
information on why this practice is bad and how to disable it.

For MediaWiki, the removed todo comment says it all. Doing this
messes with all of the super globals and makes embedding MediaWiki
inside another application problematic. It also increases our
memory footprint for every single request even when the data might
not be used.

Finally, it makes it possible to instantiate new WebRequest objects
pretty much whenever you want, so there's no reason for $wgRequest
to exist anymore.

Bug: 11558
Change-Id: I4bc0392276f454ceb966547c7fbd7c8190ebbc7c
2014-07-23 20:38:31 +00:00
withoutaname
bfa75b6f45 Removed deprecated WebRequest::escapeAppendQuery()
This function was deprecated in 1.20 and slated for removal in 1.22;
there were supposed to be warnings given in 1.21 but there does
not seem to be any use of this function otherwise in core.

Change-Id: If70a4e2c1509bf3527d5f8960c14115ce4ab713e
2014-06-20 15:11:03 -07:00
Aaron Schulz
5d6864ccf1 Cleanups to WebRequest::getIP logic
* Throw an error if there is no immediate server IP, otherwise the
  XFF logic is wonky.
* Refactored the loop to be a bit easier to read.
* Better handle "unknown" entries in the XFF chain.

Change-Id: I9541afa408d895c3fd337a883ecfe4ce0ba57090
2014-06-11 09:59:14 -07:00
Thiemo Mättig
c10b4698f0 Fix broken @return documentation
I found one of these in Wikibase and run a global search.

Change-Id: I76c1519a47d7222f136272c59ea454b650808a86
2014-05-24 22:06:01 +02:00
Brandon Black
e323bc3393 Speed up CIDR matching from $wgSquidServersNoPurge
This adds a new generic library class IPSet, which precomputes
a reasonably-efficient data structure from the input list of
addresses and CIDR net/mask specs for fast runtime matching,
and then uses it to check trusted XFF-setters.

See also: 32b4f19f173fc5cff1029eedee63a39a2d72dd3a
Bug: 57021
Change-Id: Ia3b12fb90c3e7e492374a128943b014481cc2730
2014-05-15 17:23:12 +00:00
Siebrand Mazeland
4b8523198f Make phpcs-strict pass on includes/ (4/~10)
Change-Id: I2767205a7059adfb8fa090a82abd332e518f2590
2014-05-11 19:35:09 +00:00
csteipp
a43530d825 Initialize static input to null
Followup to I8710844f21d21cbbf28517b0cc25b0713b506bee.

Change-Id: I1163deeaf18a31480ed425c7aedd0024591fd4ce
2014-05-01 12:58:46 -07:00
umherirrender
23bb3d1cb4 Follow-Ups to "Fixed some @params documentation"
Fix of inline comments of the following patch sets:
Follow-Up: I0056b4a8df243cfc0c5f25378de48f7a35170aca
Follow-Up: I7f605aa9e117b5fd80d9b1440864fe526d2b14a5
Follow-Up: I3622f216a2ca8ac1b5e51892be9f98665f65bc36
Follow-Up: I6627ba0e76d3577c40bf2473e0f78a5ad7368634
Follow-Up: Id75b5ecf648ca50f955b3bde3307c82c4366b102
Follow-Up: I4ca5231119f33039d91da3b57a41cd40719a576b

Change-Id: Id9bbe84b2820e9db44af5783411e955f55f643d4
2014-04-23 13:39:49 +02:00
umherirrender
30fe862c20 Fixed some @params documentation (includes/[WebRequest.php|Xml.php])
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: I4ca5231119f33039d91da3b57a41cd40719a576b
2014-04-23 10:28:46 +00:00
Ladsgroup
1ba0445c12 Changing URLs of mediawiki.org in scripts to the SSL-based website
http://www.mediawiki.org --> https://www.mediawiki.org

Part 2

Change-Id: I3be61fe3dfb502cc20180486eb1a8016eac151df
2014-03-12 23:24:03 +00:00
jenkins-bot
996771f720 Merge "Revert "Limit searches at 500 per page"" 2014-02-11 18:05:05 +00:00
Chad
e56e3ce5e9 Revert "Limit searches at 500 per page"
People seem to like large slow search pages.

This reverts commit 42d4f35696.

Change-Id: I52ee602a81c1b6ec4e124008806271b0c74c581c
2014-02-11 01:03:45 +00:00
umherirrender
bda7e863ef Ignore 'unknown' in XFF
Can come from Squid
http://www.squid-cache.org/Doc/config/forwarded_for/

Bug: 57467
Change-Id: I3fd3170d31a1aff2e748302c30dd6e364ed3bdcd
2014-01-28 00:39:20 +00:00
jenkins-bot
3de8536d3e Merge "Remove classes and functions deprecated in MediaWiki 1.17" 2014-01-09 21:11:51 +00:00
Chad Horohoe
42d4f35696 Limit searches at 500 per page
* 5000 search results in a single page is too many to be useful and
  just results in a slow page load. If you need that many results use
  the API.
* Adds new parameter to WebRequest::getLimitOffset() to allow making
  the 5000 limit configurable by callers

Change-Id: I7c12e4b0526db6453aaba5d589ee1c01a54b72d4
2014-01-09 10:38:19 -08:00
Siebrand Mazeland
52ba6500df Remove classes and functions deprecated in MediaWiki 1.17
Removed classes:
- WikiError (deprecated in 1.17)
- WikiXmlError (deprecated in 1.17)
- WikiErrorMsg (deprecated in 1.17)

Removed methods:
- ApiBase::getValidNamespaces() (deprecated in 1.17)
- ApiMain::setCachePrivate() (deprecated in 1.17)
- ApiMain::setVaryCookie (deprecated in 1.17)
- CategoryViewer::addSubcategory() (deprecated in 1.17)
- WebRequest::getFileSize() (deprecated in 1.17)
- WebRequest::isPathInfoBad() (deprecated in 1.17)

Change-Id: Id715c2391742c136d09f5369f88d67e798842af7
2014-01-05 18:54:27 +01:00
Siebrand Mazeland
c6178d229c Remove unreachable statement
Change-Id: I537d189e802c6201a4c9a1a5f17ca172836ec5b3
2013-12-27 17:34:55 +01: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
Reedy
b38473c328 Make WebRequest::protocol protected as it's used in subclasses in the same file
Change-Id: If894e9122fa56e957c666c887fb33ed60733ac0e
2013-11-23 01:08:44 +00:00
Siebrand Mazeland
1032c5c3da Add documentation for DerivativeRequest::__construct
Change-Id: I20e62d07b6a069b3c2b5b0cb67736ded294bcfb2
2013-11-16 20:07:19 +00:00
Bartosz Dziewoński
9a61734fb7 FormOptions: Implement FLOAT type
Also added WebRequest#getFloat().

Change-Id: I854f09bd26287880a2806852274471904bc33092
2013-11-07 23:50:59 +01:00
Tim Starling
8af1c9503d Introduce WebRequest::getProtocol()
The use of static server detection outside of its intended use case
(i.e. at the start of DefaultSettings.php), for example in r93258, was
an architectural error. Every other bit of information about the web
request in non-setup code comes from non-static methods of WebRequest,
which allows the request object to be meaningfully replaced or
subclassed. The situation became increasingly ridiculous as more
callers of WebRequest::detectProtocol() were introduced. Two of the
callers were calling it non-statically! I suppose they had the right
idea, in a way.

Using a non-static call allows caching, which is a nice additional
benefit.

WebRequest::detectProtocolAndStdPort() was introduced in r93258 as part of
the introduction of WebRequest::detectProtocol(). It was basically
useless. Grep indicates there was only one caller in core and WMF
deployed extensions, and it is patched here.

Change-Id: Ia0a61e98fbff7a46ceaeebcb02236e5eac3df0e1
2013-11-06 21:13:10 +04:00
Aaron Schulz
382ed18a64 Detect invalid IPs in XFFs and give a more useful error message
* This will only error out if we are stuck with a CDN or site proxy IP

Bug: 54288

Change-Id: Ib81e06527c2f7a8d9c288b56c0f46610a4517f74
2013-09-19 23:05:27 +00:00
Chad Horohoe
9c57e5f5f5 Protect against non-arrays when fetching headers
PHP documentation says this can theoretically return false on failure.

HHVM actually returns null when running from the command line, so
this does protect against that.

Change-Id: I0d75b8ed209128a9667ce1e7189597ae9ebc8af6
2013-09-17 10:38:14 -07:00
Max Semenik
cfc0770ad0 Normalize IPv6 addresses in XFF chains
Otherwise, we're at proxy's mercy for using the same form of IPs.

Change-Id: I090947958bf699ee6d8a9009c9e4a6d11da23f2c
2013-08-30 00:55:38 +04:00
csteipp
8ef4572700 Add methods to get raw request in WebRequest
Make it possible to get the raw parameters given to the request, with
no escaping. This is needed for features like OAuth, where a signature
is calculated over the parameters to verify their integrity and source.

FauxRequest is extended so the original request doesn't pollute the
fake one. This could be extended so "raw" values could be set and used,
but there isn't a use case for that yet, so it's not done here.

Change-Id: I8710844f21d21cbbf28517b0cc25b0713b506bee
2013-07-29 16:52:17 +00:00
jenkins-bot
00073f299b Merge "Make headers in FauxRequest case insensitive" 2013-06-03 15:06:43 +00:00
daniel
1da2dd7983 Make headers in FauxRequest case insensitive
HTTP headers are case insensitive per spec, and WebRequest
treats them like that, so FauxRequest should too.

Change-Id: I4257af7a8de2792ac556c670dcc7f28e4af4cb44
2013-06-03 16:23:11 +02:00
Aaron Schulz
8bd6922ab0 WebRequest::getIP() cleanups.
* Always treat the first XFF IP from cache proxies as sane
  even if it is a private IP (useful for things like labs wmf).
* Make sure IP::canonicalize() gets called if the IP is selected
  from the XFF chain (this matches getRawIP()).
* Altered and expanded unit tests.

bug: 48919
Change-Id: I350aca72c7a96ba3ec727324800612fc84e0e7a4
2013-05-30 18:24:43 +00:00
Tim Starling
196865004d Remove taint support
Venema's taint feature was apparently never publicised beyond the
php-dev mailing list, and now there is a PECL taint extension which is
incompatible with the interface assumed here.

Grep confirms that wfArrayMap() is not used in any extensions.

Change-Id: I17d8d302947443262474c608829c7c7504bef589
2013-05-06 17:39:07 +10:00
umherirrender
ef2f507d23 Fixed spacing in files direct in includes folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: Ibb8dd102db045522d12ff939075ba7420d95ab6b
2013-04-21 06:38:49 +00:00
Kevin Israel
516fcfe0ca WebRequest::getRequestURL: Follow up Ibe00a6b8
* Only match consecutive slashes at the beginning of the URL, where
  they are actually a problem.
* Fix bug 46607 in cases where the server provides an absolute URL.

Change-Id: Ibe00a6b8722786170d09b846c1c4054b73da3d9e
2013-03-29 13:28:35 -04:00
Siebrand Mazeland
075dc3f57d Prevent PHP notice by adding isset() check
Issue was caused by change
I34c3fc9d8f9467e83cd201cb099c2d26f3a39b36

Bug: 46627
Change-Id: Ida87efc622e9e90b835473f069559817565eafc1
2013-03-28 08:42:51 +00:00
MarkAHershberger
5a266de0a4 Handle protocol-relative URLs in WebRequest::getRequestURL.
Multiple slashes at the start of the request url will look like a
protocol-relative url, so strip the extra slashes.

Bug: 46607
Change-Id: I34c3fc9d8f9467e83cd201cb099c2d26f3a39b36
2013-03-27 17:55:58 +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
Aaron Schulz
f31a0463aa Fixed importScopedSession() and moved exportUserSession() to RequestContext.
* Renamed WebRequest::exportUserSession -> RequestContext::exportSession.
  Updated the only callers of this new function.
* Init the user with User::newFromId() instead of relying on the session
  (which breaks when things like CentralAuth are enabled).
* Made RequestContext::exportSession() include the user ID.
* Removed now-redundant user ID checks in upload jobs.
* Added unit tests for the session import function.

Change-Id: I543e6766f7a8a828ea5d270328c3bc7738c6fe94
2013-03-15 12:49:54 -07:00
Yuri Astrakhan
9506e3d812 Spellchecked /includes directory
* Ran spell-checker over code comments in /includes/
* A few spellchecking fixes for wfDebug() calls

Found one very strange (NOOP?) line in Linker.php - see "TODO: BUG?"

Change-Id: Ibb86b51073b980eda9ecce2cf0b8dd33f058adbf
2013-03-13 03:42:41 -04:00
Tyler Anthony Romeo
4dcc7961df Fixed @param tags to conform with Doxygen format.
Doxygen expects parameter types to come before the
parameter name in @param tags. Used a quick regex
to switch everything around where possible. This
only fixes cases where a primitve variable (or a
primitive followed by other types) is the variable
type. Other cases will need to be fixed manually.

Change-Id: Ic59fd20856eb0489d70f3469a56ebce0efb3db13
2013-03-11 13:15:01 -04:00
Reedy
c3e4057e06 Kill off numerous unused variables
Change-Id: I7039f1328f37ee669b694f73ee282602186bffd1
2013-03-08 02:36:24 +00:00
umherirrender
de7380b56e Change intval( User::getOption() ) to User::getIntOption()
Also changed some getOption with int or bool cast

Change-Id: Ia551a50e9de047c62be84065481fdf8c02e2ef96
2013-03-04 14:08:48 +00:00
Aaron Schulz
fbf34d84ab [Upload] Moved async upload stuff to the job queue.
* (bug 44080) Also carry-over the IP and HTTP header info.
* This adds a RequestContext::importScopedSession() function.

Change-Id: Ie9c0a4d78fb719569c8149b9cc8a5430f0ac5673
2013-02-15 15:00:35 -08:00
umherirrender
ca31ebad3f fix some spacing
Added/removed spaces after opening/before closing parentheses

Added a space after a comma

Removed unneeded parentheses in condition

Change-Id: I306091347ccaaf11dee0cdfda3019cb0c12be51b
2013-02-09 23:03:53 +01:00
umherirrender
1044b0b8df fix some spacing
Change-Id: I8f976013f33c5818e4402604fe8610aa3f43b0c6
2013-02-04 20:18:33 +00:00
Alex Monk
c2c982c4e8 (bug 36537) Rename calls to wfArrayToCGI to wfArrayToCgi
Done with this command:
grep wfArrayToCGI * -R -l -Z | xargs -0 -l sed -i -e 's/wfArrayToCGI/wfArrayToCgi/g' && git checkout -- HISTORY

Change-Id: If7f4d4bfc199289c11c43cf519c2415a1aad1c51
2013-01-28 18:04:20 +00:00
umherirrender
9d6575af15 The static declaration must come after the visibility declaration
From phpcs

Change-Id: Ieab0207f965630eda113abdc0259aa2eddcf5ca7
2013-01-26 21:03:52 +01:00
Niklas Laxström
833f87a037 (bug 44010) FauxRequest leaks cookie data from primary request
Change-Id: I6baf972352fd69660c09a5d413ff55b81aa31305
2013-01-16 09:45:36 +00:00
awjrichards
b786347996 Makes WebRequest::detectProtocolAndStdPort() take HTTP_X_FORWARDED_PROTO headers into account
Change-Id: I4debf1460b6357962fc634f781416929bcca2d76
2013-01-03 15:46:34 -08:00
IAlex
3b0f9bfe28 Merge "Tidy up some unbalanced returns in methods" 2012-12-09 09:48:40 +00:00
Reedy
d537d96868 Add numerous missing @throws to method documentation
Change-Id: Iba868e82a75fef7c7d011bc5be192bf059d037c0
2012-12-09 03:09:48 +00:00
Reedy
d0a242abb4 Tidy up some unbalanced returns in methods
Leave a TODO

Change-Id: Ic49ac8630650b341aafb3c17abd22f3a07805d27
2012-12-09 02:59:04 +00:00
umherirrender
e5f5e95137 Fix indentation whitespace errors
Change-Id: Ie268bee2098c589c050e1b5b0e93fe1b3feca86f
2012-10-26 17:42:13 +02:00
Aaron Schulz
5e2ac408f8 Merge "(bug 26585) Detect CSV/array values in $_SERVER['REMOTE_ADDR']." 2012-10-23 21:18:21 +00:00
Tyler Anthony Romeo
c4ed43cf6b (bug 26585) Detect CSV/array values in $_SERVER['REMOTE_ADDR'].
Changed WebRequest::getRawIP to check for values of
$_SERVER['REMOTE_ADDR'] that are either an array
or a comma separated list of IP addresses, and throw
an exception.

Original patch by Ilmari Karonen. Adapted from original
patch to work with newer MediaWiki version.

Change-Id: I4b3c56adf46b336c5032db3f2a1e621c873f0d83
2012-10-23 17:14:33 -04:00
umherirrender
85d8ee1f87 Remove a bunch of trailing spaces and unneeded newlines
Change-Id: I00f369641320acd7f087427ef031f3ee7efa0997
2012-10-10 20:14:40 +02:00
Siebrand Mazeland
d4b046a893 Update docs for return and exception info
* Removed some inline tabs in the process.
* IDE fixed some incorrect leading spaces, too.

Change-Id: Ic9303eff6db4424ac3f1fa2816839692b43e6190
2012-10-09 09:41:58 +00:00
Alexandre Emsenhuber
53b3c82fd7 Added WebRequest::getMethod() to get the HTTP method of the request.
This is to replace the usage of $_SERVER['REQUEST_METHOD'].

Change-Id: I45084254c5452b00b0665df78628cfd214e39cab
2012-08-07 18:28:43 +02:00
Alexandre Emsenhuber
737ccd82c6 In WebRequest, don't use isset() to check that a variable is null
Change-Id: If4577b911e774e1e0c6a1d90c585bbb027d6b7cd
2012-08-06 13:02:34 +02:00
Reedy
c61744b0d8 Suppress warnings around parse_url call
From the docs:
On seriously malformed URLs, parse_url may return false and emit a E_WARNING

We're already checking for false, but we can get spammed with E_WARNING..

Change-Id: I44a9ef2b163e64113bd2a30b081c1256ffeada1e
2012-07-28 19:50:34 +01:00
Antoine Musso
aab43dd495 escape tags and entity in doxygen comments
When inserting XML elements inline <such as this one>, doxygen chokes
about it not being known. Simply enclosing the tag in double quotes
prevents doxygen from emitting a warning.

Also enclosed a few invalid functions calls such as \. and double quoted
the HTML entities such as &foobar;

Change-Id: I4019637145e683c2bec3d17b2fd98b0c50a932f1
2012-07-10 17:08:32 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Platonides
1ea18dfaf2 Minor changes to Ic50d01f5 Accept-Language code.
Minor improvments to commit 894c5c1

Change-Id: I8cc63cb1ba2c3aa74ca9e225022d5be75e75ad23
2012-05-29 20:38:48 +02:00
Liangent
894c5c108d Tweak Accept-Language sorting method to respect RFC 3282.
Now in Accept-Language handling (in the language converter),
languages appearing earlier in the list are treated as more
preferred languages (variants).

Change-Id: Ic50d01f52dce1ae1f4f4e747d5f8b8399ca03b0b
2012-05-28 19:03:19 +08:00
Max Semenik
40e35d5b32 Deprecate WebRequest::escapeAppendQuery()
It is an ugly piece of UI-related code in an infrastructure class.
Its only user, MobileFrontend, is currently in process of getting rid of it.

Patchset 2: Fixed commit message

Change-Id: I62f9f707532a95be01c1ecdcb1fbfbd0c4117be6
2012-04-25 12:09:01 +04:00
Reedy
8f9563ce7b A set method doesn't need to return anything (and besides, niether does $this->base->setSessionData())
Change-Id: I1315697ee2879898b033c1dd01fecb809c4fe0dd
2012-04-07 17:21:16 +01:00
Daniel Friesen
9d83797631 Separate $wgArticlePath from $wgUsePathInfo.
- $wgUsePathInfo is now only used on servers not passing REQUEST_URI to determine if PATH_INFO should be used
- WebRequest now extracts information from REQUEST_URI even when $wgUsePathInfo is false
- HTMLForm bases it's decision on whether or not to include a hidden 'title' input on whether $wgArticlePath uses a query instead of assuming that $wgUsePathInfo was used to set the article path

Change-Id: I1b461fef88b26d045f4edd7553b59255c5e595d8
2012-03-24 03:44:08 -07:00
Benny Situ
586285e1f3 followup to -r113545 - add null for missing $default param 2012-03-10 00:31:54 +00:00
Roan Kattouw
f5f30aa959 (bug 34521) Returning to the previous page after logging in loses any array-valued parameters in the query string. This happens because WebRequest::getValues() calls getVal() which strips arrays, even though the doc comment says that no transformation is applied. Changed getValues() to call getGPCVal() instead. The only difference is that arrays are no longer stripped, so the doc comment is no longer a lie 2012-03-09 23:27:28 +00:00
Niklas Laxström
7476c290d3 Hrrrmp *grumbles* 2012-03-01 13:38:49 +00:00
Arthur Richards
1c242d9690 Added unsetVal() method as antithesis to setVal() 2012-02-29 21:56:05 +00:00
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
0a626db6e1 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:29:36 +00:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Mark A. Hershberger
2d72930472 w/s 2012-02-07 13:05:31 +00:00
Sam Reed
657ecdebfa Add @since to getIP/getRawIP
Came in r94932, soemwhere after 1.18 was branched, so is in 1.19
2012-02-06 20:20:43 +00:00
Antoine Musso
ffbb4a0ed2 FauxRequest now has empty data per default 2012-01-09 10:42:44 +00:00
Jeroen De Dauw
0b105ebf1d added missing deprecation notices 2011-12-13 19:51:03 +00:00
Daniel Friesen
8ddf933100 Followup r104676, r104688:
- Update our woefully out of date doc comment for WebRequest::getPathInfo (we haven't simply been extracting a PATH_INFO for ages)
- Make PathRouter::makeWeight protected
- Add more comments to the PathRouter code
- Add two more edge case tests to the PathRouter tests.
2011-12-09 00:28:34 +00:00
Daniel Friesen
fba28f5233 Followup r104688, reintroduce the full PathRouter code now that the bug with url encoded paths is fixed. 2011-11-30 15:12:19 +00:00
Brion Vibber
73b6bd244a Revert r104274, r104284, r104285 -- breaks special pages on non-english 2011-11-28 19:55:49 +00:00
Daniel Friesen
63e93db2d8 Implement path routing code.
- Makes extending paths with extensions simpler.
- Should fix bug 32621 by parsing paths based on pattern weight rather than pattern order.
2011-11-26 16:29:25 +00:00
Daniel Friesen
ae1d5aefbf Update img_auth.php and WebRequest code to handle non index.php scripts like img_auth.php better.
Also update img_auth.php so it's abuse of $wg variables is done in a way that doesn't let "/*" action paths clobber it's handling.
This should theoretically fix bug 32486.
2011-11-24 09:55:33 +00:00
Roan Kattouw
0a4f6dd7ac Revert r102949. Broke tests (undefined variable $_SESSION because session_start() hadn't been called) and is unnecessary because we have DerivativeRequest now 2011-11-14 09:23:58 +00:00
Roan Kattouw
eca300daff Followup r101149: make FauxRequest::__construct() use $_SESSION if the session parameter isn't given 2011-11-14 08:40:06 +00:00
Alexandre Emsenhuber
0510056e5a Fix for r101858: forgot the override those methods 2011-11-03 19:25:30 +00:00
Alexandre Emsenhuber
df4b6e4c3a Per Aaron, fix for r89405: introduced DerivativeRequest to allow to override the request parameters, but not headers, cookies and session. Updated ApiEditPage (for the bug) and ApiLogin (for future use) 2011-11-03 19:14:46 +00:00
Sam Reed
450814de00 More documentation updates 2011-10-28 18:11:47 +00:00
Sam Reed
6906724935 Add, update, tweak documentation
Fix document comment blocks

Tweak some returns
2011-10-26 03:45:13 +00:00
Platonides
6dbe098f27 It is valid (albeit silly) to specify lang;q=1.000 No more than three decimals are allowed.
(rfc2616 section 3.9: Quality Values)
The language-range may contain more than one - (section 14.4) such as x-pig-latin
(section 3.10: Language Tags)
2011-10-19 15:15:08 +00:00
Sam Reed
1c6f95fec3 Documentation
Explicit member variable definitions

Simplify some code
2011-10-18 17:27:52 +00:00
John Du Hart
58685f9fd5 Followup r95921, clearer PHPDoc and better variable names per CR 2011-09-29 20:21:32 +00:00
Sam Reed
27ec1d6377 Comment out unreachable code
Remove unreachable return false;
2011-09-21 16:34:23 +00:00
Alexandre Emsenhuber
ec9b551ca9 * Added HttpError exception as replacement for wfHttpError(); changed alls core calls to it except AjaxDispatcher.php
* Changed FeedUtils' call to it to be similar than feeds are completely disabled
* Use local context instead of global variables in Special:Userlogout
2011-09-16 18:50:13 +00:00
John Du Hart
5d7fe3069e (bug 4381) Magic quotes cleaning is not comprehensive, key strings not unescaped 2011-08-31 23:15:16 +00:00
Sam Reed
3e928b4d33 Tidy up w/c
Remove trailing whitespace, add some documentation
2011-08-31 14:47:08 +00:00
Roan Kattouw
f174bb0ad0 Reverse a bad decision in r93820, which added a comment to WebRequest::getFullRequestURL() saying it would return protocol-relative URLs if $wgServer is protocol-relative. This behavior makes no sense, though, and most callers expect fully qualified URLs. So make it return a fully qualified URL and update the one caller that expected the return value would be compatible with getFullURL() 2011-08-19 13:25:43 +00:00
Alexandre Emsenhuber
77a3987052 Moved wfGetIP() to WebRequest::getIP():
* Changed all calls in core to the latter
* Also marked wfGetForwardedFor() as deprecated
* Moved wfGetIP() tests to WebRequestTest
2011-08-18 20:03:30 +00:00
Sam Reed
53851419a1 Upstreaming wikia change to WebRequest
Trim trailing whitespace

Tweak documentation
2011-08-18 00:54:06 +00:00
Daniel Friesen
0139030f2b Improve the ability for extensions to participate in how MediaWiki handles url paths:
- Allow extensions to hook into WebRequest::getPathInfo and add to or alter the way titles are extracted from paths
- Add a $variant argument to the GetLocalURL hook; It's always had $query, but never had $variant. As a result extensions using GetLocalURL never new if getLocalURL and have the possibility of trying to change the url in cases where they shouldn't and as a result breaking links on wiki with language variants.
- Add GetLocalURL::Internal hook for non-interwiki links. These kinds of links internally use a ugly hack for action=render and an extension using GetLocalURL can be buggy in render mode if they don't re-implement the same ugly hack that MW does. This ::Internal hook runs before the hack does so extension authors don't need to be exposed to our ugly hacky code.
- Add GetLocalURL::Article hook specifically for url tweaks to pretty urls (ie: Only when we would apply $wgArticlePath); This hook avoids the need for extensions that only want to tweak pretty url output. This hook avoids the need to make a bunch of tests for things like !$title->isExternal(), $query == '', and $variant === false which getLocalURL does and could potentially change in the future making wider GetLocalURL hooks change in function requiring extension updates.
2011-08-12 19:23:43 +00:00
Roan Kattouw
6adb2e86a5 Some random URL protocol forcing for protocol-relative URLs 2011-08-03 12:58:21 +00:00
Roan Kattouw
e2b9cc8899 (bug NNNNN) Rewrite most of wfExpandUrl() to handle protocol-relative URLs properly and more flexibly
* Fix a bug in rNNNNN where URLs like '/wiki/Foo' weren't expanded completely if $wgServer was protocol-relative. This caused bug NNNNN.
* Add an optional second parameter to wfExpandUrl(), which takes one the PROT_* constants. This allows the caller to determine which protocol should be used if the given URL is protocol-relative, or the given URL is domain-relative but $wgServer is protocol-relative. The options are PROT_HTTP (use http), PROT_HTTPS (use https), PROT_RELATIVE (keep the URL as protocol-relative), and PROT_CURRENT (use http if the current request is http, or https if the current request is https; this is the default).
* Factor the protocol/port detection part of WebRequest::detectServer() out into detectProtocolAndStdPort(), and add detectProtocol() as a wrapper. The latter is used by wfExpandUrl() in PROT_CURRENT mode.
* Rewrite the test suite to test all possible combinations of $wgServer, $defaultProto, $url and HTTP/HTTPS mode. This means the test suite now has 120 test cases rather than 4.
2011-07-27 08:21:40 +00:00
Aaron Schulz
b1193eec5f * Broke long Wiki.php lines
* Added getValueNames() function to WebRequest.php
2011-07-13 18:05:44 +00:00
Sam Reed
6102b8fab8 More return documentation and trimming trailing whitespace 2011-06-30 02:59:43 +00:00
Brion Vibber
f569ab1005 Tweak doc comments on WebRequest::getRequestURL() & WebRequest::getFullRequestURL() per in-person discussion with preilly; the docs were unclear as to whether the query string is included (it is). 2011-06-29 23:35:05 +00:00
Sam Reed
8bfd19b451 Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits (3/3), so hopefully reviewable in CR...
2011-06-17 16:05:35 +00:00
Tim Starling
b4311ca022 Fixes for r90105, r90193:
* Actually removed $wgProto.
* Per Aryeh's suggestions on the future of $wgServer: made $wgServer detection in DefaultSettings.php more permanent by merging it with the new code from r90105. This means that bug 14977 is properly fixed now. 
* Require entry points to set up the autoloader before including DefaultSettings.php. Comments on bug 14977 indicate that at some point in the past, this may have broken something. Anything that breaks now should just be fixed, we need the autoloader. Tested the most common entry points.
* Since the detection code has moved from Installer to WebRequest, I also moved the relevant test file and updated the test. The function under test is now public static, so r90154 is superseded.
2011-06-16 05:52:16 +00:00
Tim Starling
d9c41a6819 Fixed typo in comment. 2011-06-10 11:32:28 +00:00
Tim Starling
f3f1fcdc2c * Added a REQUEST_URI check to the bug 28235 handling.
* Moved most of the bug 28235 code out to a separate library class, since I was running out of distinct function names. 
* Merged the QUERY_STRING and PATH_INFO security checks, since they are dealing with the exact same problem. Removed WebRequest::isQueryStringBad(). 
* Deal with img_auth.php by having it specify what extension it expects to be streaming out. This extension can then be compared with the extension that IE might detect.
2011-06-06 11:59:20 +00:00
Platonides
923f44359b Follow up r60599. Make normalizeUnicode() work even if $wgContLang is still not set,
just as it did before (eg. getGPCVal() check). This allows for early calls before
MediaWiki is completely initialised.
2011-06-04 21:19:07 +00:00
Tim Starling
97ff30ddb4 (bug 28840) If the query string hits bug 28235, redirect to a safer URL instead of showing an unhelpful error message. IE 6 will only use the extension of the final destination for its cache filename. 2011-06-03 05:32:51 +00:00
Platonides
641f485965 Document r89248,r89249 isQueryStringBad() 2011-06-01 21:22:53 +00:00
Tim Starling
fcdb441ff8 Fix for r89248: don't run the regex if findIE6Extension returns false. Only affects performance, the logic is the same. 2011-06-01 02:05:18 +00:00
Tim Starling
a9b9efecb4 * Only blacklist query string extensions which match /^[a-zA-Z0-9_-]+$/. This avoids blacklisting pretty much every api.php URL with a dot in it, due to extensions like "webm&smaxage=3600&maxage=3600&format=jsonfm" being detected. Such an extension is unlikely to be registered to a dangerous file type. The proposed regex matches all extensions registered in HKEY_CLASSES_ROOT on my Windows XP VM, but does not include the ampersand, so avoids matching multiple URL parameters.
* Fixed a logic error in WebRequest::isPathInfoBad() from r88883, which caused dangerous PATH_INFO strings to be allowed as long as QUERY_STRING was set.
* Refactored the query string checks in WebRequest and img_auth.php into a single new function: isQueryStringBad().
2011-06-01 02:01:59 +00:00
Tim Starling
529e92b283 Fixes for r88883, r89197:
* Modified WebRequest::findIE6Extension() to fix the performance issue and the hash parsing issue I noted on CR 
* In FindIE6ExtensionTest, fixed all the assertEquals() calls, I had the expected and actual around the wrong way
* Added a couple of extra tests for cases that seemed important during the rewrite.
2011-06-01 00:51:09 +00:00
Roan Kattouw
8dab43f703 (bug 28840) URLs with dots break because of IE6 security check
* Replace the overly paranoid regex with a function that simulates IE6's behavior
* Remove the UA check in isPathInfoBad(), was causing more problems than it was worth
* Revert r87711, going back to using dots for dots in ResourceLoader URLs, instead of exclamation marks
* Append &* to ResourceLoader URLs. * is an illegal character in extensions, and putting it at the end of the URL ensures that both IE6 and our detection function will deem the URL to have no extension (unless something like .html? appears in the query string, but in that case we're screwed no matter what)
2011-05-26 09:49:45 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
Sam Reed
f985524076 More versions added to @deprecated tags
Couple of inbound calls fixed up

Some ancient code removed as it's been marked deprecated
2011-05-06 21:50:18 +00:00
Tim Starling
1db9197660 * Fix for bug 28534: IE 6 content type detection again
* Fix for bug 28639: user object instance cache pollution
* Release notes formatting tweak.
2011-05-05 05:29:50 +00:00
Alexandre Emsenhuber
4207ab0c63 * (bug 28511) Use [] syntax instead of {} for string offset access 2011-04-17 07:59:58 +00:00
Niklas Laxström
6d43e71d2a Fix regression introduced in r82451. Only happens when getAllHeaders was not called before LanguageSelector hook was executed, not sure in which conditions this happens or not. 2011-04-14 11:58:52 +00:00
Tim Starling
7aeb423a6e (bug 28507) Fix for r85844: that revision was not actually sufficient to fix bug 28235, since URLs can have more than one question mark in them. 2011-04-14 07:10:59 +00:00
Tim Starling
ccb27f0b59 Check all MSIE requests since we also want to protect IE 3-5 etc. 2011-04-12 01:26:17 +00:00
Tim Starling
3ef857fe4d Fix for bug 28235: IE6 looks for the file extension in the query string 2011-04-12 00:55:10 +00:00
Alexandre Emsenhuber
60f1302644 Per Platonides, fix for r82686: make ApiUploadTest work again
Added option request parameter to User::editToken() and User::matchEditToken() and use them where possible from the api.
Also removed $_SESSION usage since it's no longer needed
2011-03-02 12:52:47 +00:00
Alexandre Emsenhuber
7a62c8d542 Factorise common code:
* Made appendQuery() use appendQueryArray() by using wfCgiToArray()
* Introduced getQueryValues() to get values passed in the query string; FauxRequest will return an empty array when faking a POST request
2011-02-23 20:23:35 +00:00
Alexandre Emsenhuber
8e7741c77d Merged retrieval of request URL and header from WebRequest and Setup.php to avoid duplicate code and reduced the number of wfDebug() calls in Setup.php.
The only side effect is that headers name are in uppercase in the debug log.
2011-02-19 13:09:17 +00:00
Mark A. Hershberger
0677934401 * recover dropped check of $wgUsePathInfo from r81363
* document getPathInfo
2011-02-02 15:44:37 +00:00
Sam Reed
49b6b1cc61 Followup r81373, r81363
PHP Notice:  Undefined variable: matches in /home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/includes/WebRequest.php on line 109

Explicitally define $matches at top of function, allowing it to always be defined for all paths
2011-02-02 13:02:45 +00:00
Mark A. Hershberger
72dd2cf8c6 follow up r81363 and fix Bug#27099 2011-02-02 03:14:37 +00:00
Mark A. Hershberger
9de57fff82 * Remove last bit of code that uses PATH_INFO from img_auth.php so that people who want to use protected images on hosts with sadly mis-shapen PHPs (e.g. GoDaddy) can.
* Mangle PATH_INFO handler in WebRequest so that all the relevant bits are in a (couple of) static functions.
2011-02-02 01:08:15 +00:00
Mark A. Hershberger
a2ec67cfb5 Whitespace cleanup 2011-02-01 23:08:10 +00:00
Sam Reed
4ee5d368db Followup r72119, add some braces
Document $db in parserTest
2011-01-07 00:55:09 +00:00
Ilmari Karonen
fec364732f followup r78209: fix typo, better word choice 2010-12-10 22:42:46 +00:00
Ilmari Karonen
75086e9f35 (bug 16019) Make WebRequest::interpolateTitle() do nothing when run from api.php 2010-12-10 22:39:17 +00:00
Chad Horohoe
f3054e5787 Drop silly $_ prefix from 4.x days 2010-11-05 12:59:37 +00:00
Chad Horohoe
0f149cf548 Document return type. Autosuggestion and the like :) 2010-11-05 12:54:58 +00:00
Trevor Parscal
dc723fc710 * Improved on r73567, this makes WebRequest::getFuzzyBool case insensitive, making 'false', 'FALSE', 'FaLsE', etc to be boolean false
* Fixed syntax error in Skin.php
2010-09-27 15:59:58 +00:00
Chad Horohoe
e4189f5920 Fix a bunch of '? true : false' instances 2010-09-27 14:24:13 +00:00
Trevor Parscal
6de8690746 * Added WebRequest::getFuzzyBool, which is a more JavaScript friendly version of getBool. Essentailly the same thing, except the string 'false' is also considered boolean false.
* Made use of getFuzzyBool where otherwise awkward and sometimes varied versions of 'flase' === false detection were being used.
2010-09-22 20:15:31 +00:00
Sam Reed
ecf56c33fa Braces and spaces 2010-09-04 03:43:33 +00:00
Mark A. Hershberger
3751511ff0 fill out appendQuery() for FauxRequest — probably should be refactored
into the parent class, but the parent uses $_GET where we have $this->data
2010-09-01 16:58:44 +00:00
Ryan Kaldari
aaa70d34ac Fixing comment so that method documentation isn't broken 2010-08-31 00:33:14 +00:00
Alexandre Emsenhuber
7b79d94515 * Standardised file description headers
* Added some descriptions
* Added @file where needed
2010-08-14 17:42:40 +00:00
Chad Horohoe
aa7b63ce83 Cleanup getCookie() and use it all over the place instead of using $_COOKIE directly 2010-08-06 15:00:43 +00:00
Platonides
4467d11a46 Follow up r70356.
Improve WebRequest getAcceptLang(): Add support for q=0 language and the special range "*", always return the language codes in lowercase.
2010-08-03 13:23:31 +00:00
Max Semenik
07760f5799 Follow-up to r64587:
* Use WebRequest::getAcceptLang() instead of home-brewed code (and in LanguageConverter too).
* Refactored that function to use getHeader()
2010-08-02 20:16:36 +00:00