Commit graph

18 commits

Author SHA1 Message Date
Ebrahim Byagowi
a717db8e60 Add namespace and deprecation alias to FormatJson
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
2024-05-16 16:28:01 +03:30
Máté Szabó
530b6a408b WebRequest: Gracefully handle array values in getCookie()
Given a cookie header like "Cookie: foo[]=bar;foo[]=bar2', PHP will
assign $_COOKIE['foo'] = [ 'bar','bar2']. This is not expected by
callers in MediaWiki and can trigger various errors in code that does
not expect to be dealing with arrays in this situation, nor is it
specified by RFC 6265[1] or any of its predecessors. So, stick to RFC
semantics here and treat the cookie as absent, since the name foo[] is
not the same as foo.

[1] https://datatracker.ietf.org/doc/html/rfc6265

Bug: T363980
Change-Id: Idaa175234de2d25a90e6be8fb6279c39089726bd
2024-05-02 12:05:43 +02:00
Robert Timm
7026c5cd0b WebRequest: detectServer appends default ports that should be omitted
In MediaWiki 1.41.0 the function WebRequest::detectServer() started to generate server URL strings containing default ports such as 80
for http and 443 for https.

Before 1.41.0: https://my.wiki
After  1.41.0: https://my.wiki:443

detectServer() uses IPUtils::combineHostAndPort() to build the URL. The
latter function has actually a mechanism built in that intends to omit
standard ports, so the new behavior in MW 1.41.0 seems unintended.

As this broke WDQS over here in our Wikibase Suite bundle, I
investigated the cause.

MediaWiki 1.41.0 updates IPUtils from 4 to 5. With this update, there
was a change that compares the port now via === instead of ==.
(e68cf6a14e%5E%21/#F1
Line 383) The new behavior is correct, as the function expects an int.
MediaWiki passes in a string though. This bug was hidden with IPUtils 4,
but is triggered now in IPUtils 5.

I think this should be backported to REL1_41.

Change-Id: Ib707ee72e02cf99225168d268d5fedab3f548ead
Bug: T360608
2024-03-28 11:03:28 +00:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +00:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
jenkins-bot
bf22917ed1 Merge "entrypoint: Isolate entry points from PHP runtime for testing" 2024-02-02 19:59:11 +00:00
daniel
24d0aee05e entrypoint: Isolate entry points from PHP runtime for testing
1) Introduce EntryPointEnvironment which wraps functions that interact
with the PHP runtime, so they can be mocked for testing.

2) Allow server info fields to be overwritten in FauxRequest.

3) Make MediaWikiEntryPoint use WebResponse to set headers

Bug: T354216
Change-Id: Ic21950c956de5d2b5a7dd66a1e2de58f807cfd9f
2024-02-02 13:03:29 +01: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
Umherirrender
a3a9cf99cb tests: Use namespaced class names in @covers annotations
Assist from 8c9cb701e56226cac43fee2fa24b0d0e586f1733

Change-Id: I47897c499028d9e24c00ad0bc6ba7fd8002d9bc1
2024-01-27 01:11:07 +01:00
Umherirrender
388b0374fa tests: Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statements and changes to docs done manually

Change-Id: Ib326ae1e5c8409a98398c721e8b8ce42c73bd012
2023-12-11 15:59:55 +01:00
jenkins-bot
317bcdbbbc Merge "ContentSecurityPolicy: Expose directives" 2023-11-15 20:11:33 +00:00
jenkins-bot
1deb97933a Merge "ContentSecurityPolicy: Add test for sendHeaders" 2023-11-15 20:11:23 +00:00
jenkins-bot
efa0ef4fe0 Merge "ContentSecurityPolicy: Clear hooks during tests" 2023-11-15 20:11:10 +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
Gergő Tisza
f5cd4452b1
ContentSecurityPolicy: Add test for sendHeaders
Bug: T169027
Change-Id: I46a6ee7eaff57d3fa134a5e6e1373d5b0e1f381e
2023-11-14 20:43:35 -08:00
Gergő Tisza
81cf4fe95e
ContentSecurityPolicy: Clear hooks during tests
This makes the tests pass when extensions adding custom policies
are enabled.

Bug: T169027
Change-Id: If5b19ae7885a82f8de2acb7440146079eece10c1
2023-11-14 20:43:34 -08:00
Máté Szabó
ddbd5735a0 WebRequest: Fix PHP 8.1 deprecations in getFuzzyBool()
WebRequest::getFuzzyBool() will emit a deprecation warning on PHP 8.1 or
newer if the parameter to be fetched is absent and the $default value is
set to `true`, because strcasecmp() no longer accepts nulls. Fix it by
returning out if the parameter is wholly absent and add a test for this
scenario.

Bug: T351088
Change-Id: I85bbfec6aabef4e85859a76b6e50c80781024ae5
2023-11-13 15:35:55 +01:00
Umherirrender
790ae736c1 tests: Move test cases from /includes/ into sub folder
Follow move of the tested class
Most moves are part of T321882

Change-Id: I74ab45d6a5331dcb2ff0b65dc2cc7c6315146646
2023-09-13 00:09:05 +02:00