Commit graph

1755 commits

Author SHA1 Message Date
Tks4Fish
76e3701d6a OutputPage: Remove $wgLoggedOutMaxAge experiment and related tests
Bug: T293848
Change-Id: I5e5e52fac7fe389b36715dae11cc30cdb2b9136a
2021-10-25 19:33:32 +00:00
Fomafix
e86f180bd4 Merge "Encode & to & in displaytitle fallback" 2021-10-14 17:58:06 +00:00
Timo Tijhof
d457762706 resourceloader: Remove obsolete logic for handheld=yes pageviews
This feature was removed in 2013 (Ia8d79b4a, T49504), with further
remnants removed in (1965df8df3, I7c24128f7b1).

* Simplify the code of transformCssMedia() as it now only needs to
  support printable=yes.
* Remove query parameter abstraction from test cases, use query
  array directly.
* Remove internal use of the $handheld parameter.
  Function signature of makeLoaderQuery() left in-tact for
  compatibility with $extraData. This will be deprecated and removed
  in a follow-up commit.

Bug: T49504
Bug: T32956
Change-Id: Id16ef3f4630538de1887ac2327eb317c6c6b1f9d
2021-10-09 02:47:39 +01:00
jenkins-bot
e13337b0ca Merge "OutputPage: Remove redundant "rel=edit" head link after "x-wiki" link" 2021-10-08 19:12:38 +00:00
DannyS712
736e00ee8c resourceloader: omit noscript module from client registry
In all cases where the client registry is used, the `noscript` module
is inapplicable. Additionally, make it illegal to have a module
include the 'noscript' module as a dependency.

Bug: T291735
Change-Id: I5846f2c19b003989b56b12628b385fd37049483b
2021-10-07 01:21:02 +00:00
Fomafix
eed3121a8f Encode & to & in displaytitle fallback
The value in the attribute displaytitle must contain valid HTML. The
sanitizer of the {{DISPLAYTITLE}} parser ensures that only valid HTML
is accepted.

If there is no {{DISPLAYTITLE}} in the wikitext then displaytitle
falls back to $title->getPrefixedText(). Here an HTML encoding of
special characters is necessary. This affects only the replacement of
& by &amp; because other special characters like < and > are not
allowed in the title.

This change affects the displaytitle fallback on the following places:
* ApiParse
* ApiQueryInfo
* InfoAction
* Parser

The displaytitle fallback in OutputPage is also updated to this
behavior although
Sanitizer::normalizeCharReferences( Sanitizer::removeHTMLtags( $html )
also replaces & by &amp;.

Also add test cases with & in the displaytitle to:
* ApiParseTest
* ApiQueryInfoTest
* parserTests

Bug: T291985
Change-Id: I8ee1e2731d9bfa49725d663b34986e7e3073e4ca
2021-10-05 18:09:15 +00:00
C. Scott Ananian
df3cc40fac Rename ParserOutput::{allow,prevent}Clickjacking() -> ::{get,set}PreventClickjacking()
This name is consist with the rest of the setter and getter methods
in ParserOutput.  Renamed the methods in OutputPage, ImageHistoryList,
ImageHistoryPseudoPager, and ContribsPager as well for consistency;
it also makes chasing down lingering references in codesearch easier.

Soft-deprecated the old name for 1.38.  Hard-deprecation will follow,
but there are a number of users in production that should be chased
down first.

Code search:

https://codesearch.https://codesearch.wmcloud.org/deployed/?q=(allow%7Cprevent)Clickjacking&i=nope&files=&excludeFiles=&repos=

Bug: T287216
Change-Id: I9822c60c180d204bd30cb4447a1120155d456da4
2021-10-01 14:13:47 -04:00
Umherirrender
362a48e316 Change null to [] for html attributes on call of Html functions
Change-Id: Ia84f5b1f210396cba5daa7b9e8bb8c4069e0171d
2021-09-22 22:47:28 +02:00
Timo Tijhof
4c7055fcea OutputPage: Remove redundant "rel=edit" head link after "x-wiki" link
Bug: T21165
Change-Id: I53f4b8cfc117012abecdfb5e751886be8ef6cda6
2021-09-21 04:15:22 +01:00
Alexander Vorwerk
c4b2765ebd Avoid using ContentHandler::getContentText()
ContentHandler::getContentText() is deprecated and should be
replaced with Content::getText() for TextContent instances.

Change-Id: I556d3d3f64fafd1d54c4a0c5021efaff2d9c3ce8
2021-09-20 15:32:44 +02:00
Ammarpad
2d18a56d54 Soft deprecate Skin::bottomScripts
Also prepare OutputPage::getBottomScripts to handle the work of
SkinAfterBottomScripts hook in the future.

Bug: T257704
Change-Id: Ib0a8b72faa88259c24b5fb7e9d5a908423494247
2021-09-03 19:26:51 +00:00
jenkins-bot
6b115843ed Merge "Introduce OutputPage::tailElement" 2021-08-30 05:42:33 +00:00
Ammarpad
162b66b245 Introduce OutputPage::tailElement
* SkinMustache::tailElement is removed, SkinMustache now calls
the OutputPage method

Bug: T257704
Change-Id: Ief537d2c317595d192a37e8493369e08e1fb2f45
2021-08-29 11:15:07 +01:00
Timo Tijhof
e387cd9c35 Change trivial use of getVal('action') to getRawVal
Per docs added in I18767cd809f67b, these don't need normalization
as they are only compared against predefined strings, and besides
are generally entered manually in a form, and even then would not
require the kinds of Unicode chars that have multiple/non-normalized
forms.

In nearby areas to also fix some trivial cases:

* getVal('title') obviously needs normalization.
  Use getText() to make this more obvious.

* getVal() compared against simple string literals within the code
  obviously don't need normalization (e.g. printable === 'no').

* Change hot code in MediaWiki checking for whether 'diff' or 'oldid'
  are set to getCheck (which uses getRawVal) instead of getVal.
  As a bonus this means it now handles values like "0" correctly,
  which could theoretically have caused bad behaviour before.

Change-Id: Ied721cfdf59c7ba11d1afa6f4cc59ede1381238e
2021-08-26 22:11:58 +01:00
Kunal Mehta
a85f569dd1 Revert "Use CsrfTokenSet as CSRF token source"
This reverts commit 0d75fdb4f7.

Bug: T287542
Change-Id: Iedd3461869f973f8d621a39e6ad4674cbb577551
2021-08-05 15:48:26 -07:00
Jack Phoenix
b326dd4352 Remove capitalize-all-nouns CSS class support
Functionality has been moved to MonoBook.

Bug: T97892
Change-Id: I3d4d74a2caa77f975b415af5977253ddeff6af21
Depends-On: I598c4469c46d284562ea3aec79330f9a1f40d2ce
2021-07-30 16:59:36 +00:00
jdlrobson
0fc9cf4282 Remove doSetupSkinUserCss and setupSkinUserCss
These methods have been replaced by skin options.
Skins should now declare their style modules in skin.json using
the `styles` option.

Bug: T280610
Change-Id: I24abe7e2539499089e91151d9122e05bcb2d32ca
2021-07-27 08:39:25 -07:00
Derk-Jan Hartman
7b7f3ac563 Disable browser data detection of telephone numbers
Number ranges are common and easily mistaken as telephone numbers by
the data detectors of popular browsers. To link a telephone number,
use the explicit [tel:phonenumber display value] syntax.

If you want to re-enable, set the BrowserFormatDetection configuration
variable to false.

Bug: T256758
Change-Id: I49dff3c084d8c9a66defcdae5a1ffb8f35ba8a93
2021-07-26 09:39:07 +00:00
Petr Pchelko
0d75fdb4f7 Use CsrfTokenSet as CSRF token source
Change-Id: I079d2c802d9b48d6abf7f37fa9ef7dafac631345
2021-07-12 14:19:15 -07:00
Roman Stolar
6ebaa5caf6 Remove the fallback for create rights (covered in PM edit rights check).
Remove key to i18n message, no longer being used.

Bug: T272079
Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
2021-06-30 17:30:30 +03:00
DannyS712
30c10a2e8d Remove unneeded title casts
Parser::parse() accepts PageReference, and
WikiPage::factory() accepts PageIdentity

Change-Id: If8d15863045d7690fd6d965341ec8564d50db2d7
2021-06-07 13:36:03 +00:00
Mark A. Hershberger
e4a95b9b82
Stop logging and md5'ing if the file does not exist
Also bring this more in line with CSSMin::remapOne()

Bug: T283387
Change-Id: Iea5e68f48be96fae5b5640fe26c2095ca5196e88
2021-05-21 14:31:17 -04:00
daniel
fd2a9bf4a4 resourceloader: Remove Title from public interfaces
Bug: T278459
Depends-On: I9bc371fd299e7a5401ebc1b8d7456d9a4ecde90d
Change-Id: Ib3a0591766f873492ec5a24721e7840f4e1a6407
2021-05-13 10:06:30 +02:00
mainframe98
c87462097c Don't use classes error, success and warning outside parser
Bug: T280766
Change-Id: I83f2828bcde160c98a1d97e783a869e64fb4c6ea
2021-04-27 17:11:14 +02:00
daniel
c1eb74603a Remove Title from public interface of OutputPage
Bug: T278459
Change-Id: If455682540faf8d42fd8a14e0ef09bac24f72db4
2021-04-16 10:01:56 -07:00
mainframe98
20fc80577b Rename $wgSlaveLagWarning and $wgSlaveLagCritical to match DB_REPLICA
These are now named $wgDatabaseReplicaLagWarning and
$wgDatabaseReplicaLagCritical, respectively.

Bug: T277987
Change-Id: I62d8c2028fdfee00904f1058f8387499f2b2e977
2021-03-21 17:58:15 +00:00
jenkins-bot
7cc9b84af9 Merge "Convert second batch of special pages to authority" 2021-03-08 22:33:53 +00:00
Ammar Abdulhamid
242b9b2f6a Enforce concealment of hidden RelevantUser at Skin level
Skin is what takes a user or extract it from a title to set relevant
user and so this is the right place to handle permission check too
because if the user is hidden, it should be made known for all
callers, instead of hoping each caller will do similar check
which is duplication and not guranteed.

Skin:setRelevantUser always takes user and this is now typehinted to
avoid errors. Callers need to give what's required.

Bug: T120883
Change-Id: I177cd83a9c4f87c27a63d8f530c40895d0f3f5dd
2021-03-08 15:38:07 +01:00
Petr Pchelko
bfa145fae7 Convert second batch of special pages to authority
Depends-On: Ifc82d29a00d3fd136c44e0699e6bbfa11b8cf2a6
Change-Id: Iaf559a72cc47ec5d2481d7f740ad0eb303c94002
2021-03-04 15:37:59 -07:00
Petr Pchelko
244bbc8edc OutputPage: move to authority where relevant
Change-Id: Iae42cc747f80cb0215f862d633e9af32fc7c8571
2021-03-04 08:55:20 -07:00
Timo Tijhof
26c9849330 docs: Fix 'dependant' typos
The intended word in all these cases was the adjective "dependent".

Whilst the "dependant" does exist, it is a noun and generally
refers to a person. The word is rare used in general, but
especially so in a technology context.

Change-Id: Ic7e2d2ea6a566f4139ff1fdb77f38b0e962ccd9c
2021-02-18 16:59:20 +00:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Ammar Abdulhamid
e78de41070 OutputPage: Make $wgDebugRedirects work again
This was broken by I2dd2b71.

In that patch MediaWiki::outputResponsePayload() was introduced and it
added another output buffer layer on top of Outputpage::output( true )
which directly outputs and return empty string if $wgDebugRedirects is
true (and the location is redirect).

Because Outputpage::output( true ) returns empty string in that case,
the output buffer started by MediaWiki::outputResponsePayload() will
always end up with empty string, and the print() in Outputpage cannot
send the output because it's now nested inside another buffer layer
with call to ob_end_flush(), which discards contents of inner buffers.

Previously it worked because the return value of Outputpage::output()
was not wrapped in another output buffer then, so the direct print of
the html was enough to make it work.

This patch modified Outputpage::output() to return the html string if
$wgDebugRedirects is on, and return value is requested --instead of
outputting it-- that way the debug html will now be captured in the
topmost buffer layer inside MediaWiki::outputResponsePayload()

Bug: T236639
Change-Id: Ibe4e771b0530b7c6bb7132c88c8455b0ef4fde0e
2021-02-12 03:35:53 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Umherirrender
9cb5f24bb8 Replace deprecated function in OutputPage
Now mocking LanguageConverter

Change-Id: I25f2f90d8dcf2cb09429e01873f1982dca199976
2021-02-05 02:17:36 +00:00
Umherirrender
47cc4da6d7 Remove unneeded @return documentation
Change-Id: If79d2126cc1b6a6e9876a972c9560d045de42ff6
2021-01-25 19:44:27 +01:00
Ppchelko
bdb5f394d3 Revert "Enhance GroupPermissionsLookup and use it."
This reverts commit 900c6663b0.

Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.

Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
2021-01-12 04:48:49 +00:00
Petr Pchelko
900c6663b0 Enhance GroupPermissionsLookup and use it.
Added new methods:
- ::getGroupsWithAnyPermissions
- ::getGroupsWithAllPermissions
- ::groupHasAnyPermission
- ::groupHasAllPermission

Replaced relevant calls to PermissionManager with
calls to GroupPermissionsLookup.

Bug: T254537
Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
2021-01-11 11:05:54 -06:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
DannyS712
f4e21014ce Deprecate a bunch of global functions
* wfAcceptToPrefs
* wfClearOutputBuffers
* wfConfiguredReadOnlyReason
* wfDebugMem
* wfGetPrecompiledData
* wfNegotiateType

Bug: T264976
Bug: T264979
Bug: T264981
Bug: T264983
Bug: T264984
Bug: T264985
Change-Id: Ia05bc84e4d1be7c8a02472f32e2c009e4bb32032
2020-12-18 21:34:50 +00:00
DannyS712
b5e7f210cd SECURITY: Act like users don't exist if hidden from viewer
When viewing Special:Contributions for a hidden user and
a missing user, or the user page of a hidden user and a
missing user, if the viewer cannot see hidden users
the output should be the same for hidden users and
missing users.

To that end
* In OutputPage.php, only set the `wgRelevantUserName` javascript
  variable if the user is not hidden, or the viewer can see hidden
  users
* In Article.php, show the `userpage-userdoesnotexist-view` on user
  pages of hidden users if the viewer cannot see hidden users
* In Skin.php, do not add user-specific sidebar links (contributions,
  logs, mute, etc.) if the user is hidden and the viewer cannot see
  hidden users
* In SpecialContributions.php, stop calling Skin::setRelevantUser
  for non-existing users, so that callers of Skin::getRelevantUser
  can ignore users that are hidden from the viewer without creating
  divergent behavior
* In SpecialContributions.php, for users that do exist but are
  hidden from the viewer, don't show `sp-contributions-footer`,
  but do show `contributions-userdoesnotexist`

Bug: T120883
Change-Id: I83b723402f315447bc4b50992e28620e3daace8f
2020-12-18 00:35:54 +00:00
C. Scott Ananian
c64e71615e Replace $wgDisable{Lang,Title}Conversion with LanguageConverterFactory methods
Replace direct access to $wgDisableLangConversion with
LanguageConverterFactory::isConversionDisabled(), and replace direct
access to $wgDisableTitleConversion with
LanguageConverterFactory::isTitleConversionDisabled().  However, most
places that check ::isTitleConversionDisabled() actually want
::isLinkConversionDisabled(), so add that too (and deprecate
isTitleConversionDisabled()).

Code search:
https://codesearch.wmcloud.org/search/?q=Disable%28Lang|Title%29Conversion&i=nope&files=&repos=

This change removes a number of spurious dependencies on the global
configuration and reduces code duplication (for example, if the logic
for disabling language conversion were ever to change).

Depends-On: I6fa8230ae97b0e34c381003548e61f9b7387d363
Change-Id: Icc4687638ff1815003dd903854efdbd904854f1e
2020-11-25 12:47:26 -05:00
jdlrobson
d11cb401d6 Deprecate the use of Skin::setupSkinUserCss to alter the internal array of styles
Check the internal array of styles to determine whether
the method was inappropriately used to alter the array of styles and
if it was, call wfDeprecatedMsg().

Change-Id: I591b03c2e19d4b8cadfe220b498ae244d332f9fb
2020-11-24 10:49:09 +11:00
Tim Starling
e9608cc17d Revert "Deprecate Skin::setupSkinUserCss"
The commit did not really hard-deprecate overriding of setupSkinUserCss() as stated in the commit message, rather it removed core calls to setupSkinUserCss(), instantly breaking the many skins that still override it. It did not actually create a deprecation period for graceful migration.

As discussed in T267080, there is presently no way to hard-deprecate the override of a method.

This reverts commit 334cfeffd6.

Bug: T257990
Change-Id: I8f669ba30affc437800890c3a875994a9f2eb3c8
2020-11-24 10:03:11 +11:00
jenkins-bot
1976283835 Merge "Update a lot of unspecific "array" types in PHPDocs" 2020-11-13 21:48:24 +00:00
jenkins-bot
32fed9c635 Merge "resourceloader: Remove wfExpandUrl() coupling from CSSMin" 2020-11-13 07:07:49 +00:00
jenkins-bot
b8f3822d52 Merge "Reduce some references to $wgUser" 2020-11-09 14:53:37 +00:00
Brad Jorsch
cd54c03e86 resourceloader: Remove wfExpandUrl() coupling from CSSMin
There are three cases in CSSMin::remap where performs path
resolution.

1. Absolute local path URLs to full URL.
   Example: url(/static/foo.png), url(/w/index.php?…), etc.

   These previously used wfExpandUrl(), which got the server
   name and protocol directly from $wgServer.

   We will now use the $remote parameter to get this information
   instead, which is generally set to something like
   https://wiki/w/resources/foo, and thus naturally contains
   the server name and protocol.

   The resolution is powered by the Net_URL2 library, allowing
   this to work outside Mediawiki as well.

   Some tests needed to change because they were calling CSSMin::remap
   with an incomplete $remote dummy values like "/" or "/w, because
   the test author (past me) was trying to be clever by not supplying
   it, knowing MW would ignore it. Now that it is consistently used,
   like normal calls from ResourceLoader would, the expected values
   will always be based on http://localhost/w, instead of sometimes
   the competing $wgServer value of `https://expand.example`.

2. Relative local path to full URL
   Example: url(foo.png), url(../foo.png), url(bar/foo.png)

   These were already using $remote. The only change is that
   they now use Net_URL2 library instead of blind string
   concatenation. One of the benefits of this is that we will
   no longer need to call wfRemoveDotSegments() to get rid
   of things like double slashes or redundant "../" sequences.
   Previously, thing like "foo//bar" or "foo/../bar" were cleaned
   up only due to wfRemoveDotSegments(). This is now naturally
   handled by Net_URL2.

3. Remote URLs
   Example: url(http://example.org/bar.png), url(//example.org/bar.png)

   This is generally not used in source code, but gadgets may use this,
   e.g. for upload.wikimedia.org or cross-wiki imports.

Other changes:

* One test case used spaces within the URL string in CSS, which the
  net_url2 library represents with percent-encoding instead.
  Same thing either way.

Bug: T88914
Change-Id: Ibef70cc934c0ee8260a244c51bca9fb88c1c0d88
2020-11-05 19:59:02 +00:00
Tim Starling
5ada7df93e Log the reason for private caching
In OutputPage::sendCacheControl(), break up the multi-line conditional
and include in the debug log message the reason for private cache
headers being sent. I think this improves the readability of the code.

Change-Id: I0229e04c44771245b7ac8cd45d2c83062a4d78f2
2020-11-05 13:12:42 +11:00
jenkins-bot
929381a81f Merge "Use LinkBatchFactory" 2020-11-01 20:48:02 +00:00