Commit graph

10 commits

Author SHA1 Message Date
James D. Forrester
2b11d61577 Migrate all uses of deprecated URL global functions to use wfGetUrlUtils()
wfGetUrlUtils() is also deprecated, but less so, so we can do this first
and then properly replace the individual uses with dependency injection
in local pieces of work.

Also:
* Switching Parser::getExternalLinkRel to UrlUtils::matchesDomainList
  exposed a type error in media.txt where $wgNoFollowDomainExceptions
  was set to a string (which is invalid) instead of an array.

Bug: T319340
Change-Id: Icb512d7241954ee155b64c57f3782b86acfd9a4c
2024-09-10 16:50:02 -07:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +00:00
Amir Sarabadani
4c68983623 Drop deprecated config $wgAllowImageTag
Soft-deprecated since 1.35 and hard-deprecated since at least
I9776d11d4e2d184 (1.39).

Not set in production.

Change-Id: I68b68ffcdff22daafad34c186d1cc609dcecbf32
2024-01-30 11:42:54 +00:00
Gergő Tisza
6fbd223f1d
ContentSecurityPolicy: Expose directives
Instead of only exposing the ability to send CSP headers, expose
the values of the headers so they can be set via other mechanisms.

Bug: T169027
Change-Id: Ie9f7a29218392e3bc3215ce879ed2a3c48847a7c
2023-11-14 20:43:35 -08:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
f08a920152 Follow-up bfedab2: Add in-code comment on alias for when it was added
Change-Id: I20731e435a6fbf8d7f507a1627ea49d6aeb54469
2023-08-28 14:29:40 -04:00
Timo Tijhof
b28faecb2b ResourceLoader: Remove support for CSP nonce
The "nonce" CSP feature has been never been properly tested and is not
on track to be enabled at WMF or in MW by default. The use of
nonce-protected eval is not particularly meaningful. It is trivially
bypassed by mw.loader.implement, mw.loader.store, or importScript();
all of which allow any code to be executed directly, or to be stored
and loaded from a first-party origin.

The "nonce" feature is not required for the T208188 roadmap, and with
change I51b8535b2b21a3 there is now also a (small) performance reason
to keep this disabled long-term.

Until and unless there is a plan for enabling this particular aspect
of CSP, we might as well remove it so that we don't waste time our
time building abstraction layers and satisfying dependency injection
through many years for something that might never be used.

Note that this does not remove CSP support from ResourceLoader, and
does not take away from the future of enabling CSP in MediaWiki to
e.g. strictly block third-party scripts, or to require domains to
opt-in by site config or user pref (T208188).

Change-Id: I5a176c41a06a484a11e64bdacdc42b40811fe72e
2023-08-09 02:30:39 +01:00
Tim Starling
bbcd0acfd6 ResourceLoader: use Function constructor for module implementations
Profiling in Chromium 115 of a VE request with a mw.loader.store cache
hit shows that the largest domEval() takes 59ms, mostly DOM-related
overhead. Using the Function constructor reduces the time for that call
to 30ms.

Profiling in Firefox 116 shows that it is 41ms either way, there is no
significant DOM overhead.

So, use the Function constructor instead of DOM eval for normal RL
module implementations.

User scripts rely on e.g.

function foo() {}

creating window.foo, which is not the case for the Function constructor.
So for them, continue to use domEval().

The Function constructor propagates exceptions, which is beneficial,
since domEval() was called in a try/catch block. Now the catch should
be reachable.

Change-Id: I51b8535b2b21a3ed62e05c727a06dee09ba0a7b7
2023-08-04 11:09:01 +10:00
Amir Sarabadani
bc1af1a53a Reorg: Move WebResponse and FauxResponse to Request/
Bug: T321882
Change-Id: Iae8b9e0170c67c1adf861a6d0da45178a7d3cca7
2023-03-01 18:18:11 +01:00
Amir Sarabadani
bfedab2eb8 Reorg: Move CSP class to Request/
Bug: T321882
Change-Id: Ic809656a31e08626d0e5a1172da02b2397096e14
2023-02-16 13:36:41 +01:00
Renamed from includes/ContentSecurityPolicy.php (Browse further)