Commit graph

55 commits

Author SHA1 Message Date
Umherirrender ef074299ca Use namespaced classes
This requires 1.42 for some new names

Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I0f43f4db86de2990c8902a36976923ad9f0ae67a
2024-01-04 21:53:17 +01:00
Umherirrender 8808ab0a15 tests: Cover CodeEditorHooks
Change-Id: I8a094d14347bb58850b7f864320f30420b18460f
2023-11-06 19:46:50 +00:00
Umherirrender 8ef8014843 tests: Adjust mw-parser-output div for new attributes lang/dir
Add in core with d0a96db0

Follow-Up: Ib130a055e46764544af0f1a46d2bc2b3a7ee85b7
Change-Id: I016093b732fc8c44901632c4d63608c5af41cda5
2023-11-06 20:43:49 +01:00
Umherirrender b5ab3bac24 Use HookHandlers for CodeEditor hook
Bug: T338435
Change-Id: I7c2cb3ca5e38ce974187af316bf30e71b8e4ad49
2023-11-06 12:00:18 -05:00
Umherirrender 5482c272bc Use HookHandlers for core hooks
The use of "HookHandlers" attribute in extension.json makes it possible
to inject services into hook handler classes in a future patch.

Bug: T338435
Change-Id: Iadeed8e4735f95387f2faed4bc4305327bff3c8a
2023-09-24 22:12:07 +02:00
gerritbot cfa97927e4 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: Ib7950b17581d69c1c9197e3a3109d3da4c735a33
2023-08-19 12:55:12 +00:00
Umherirrender 687207f0bf Create HookRunner class and the hook handler interfaces
Bug: T338435
Change-Id: I34726d15dad5045f5c1b00ec7796b7b5f1516d12
2023-06-08 13:59:15 +02:00
Umherirrender 6b7d6f91c3 tests: Make PHPUnit data providers static
Initally used a new sniff with autofix (T333745)

Bug: T332865
Change-Id: I47b6b34d1e6159b51c14d9a5a2d21242dfbf8fff
2023-05-21 16:10:11 +00:00
Umherirrender e997750927 tests: Adjust output format for html changes (self-closing xhtml)
Follow-Up: I4bbfa47fbf6e30fb90d920d6d02cdf6e0b1cdb46
Change-Id: I06045e1011de9035f0be759d953f3145293c66f2
2023-05-21 18:07:53 +02:00
Reedy c63fc13ff1 Update wikimedia/css-sanitizer to ~4.0.0
Change-Id: Ideac939b475fb95bf33ae8a77e4c2d87e6bcb05a
Depends-On: I5d0d34a8931a22a2c7f31e0da4897be55fdedfc0
2022-07-08 19:59:25 +00:00
jenkins-bot 71d75b731f Merge "Namespace extension" 2022-03-05 16:00:06 +00:00
Reedy 5d7bc99cae Use namespaced quietCall
Change-Id: Ifcacc35721d5509c3bc1fe602587c0701af5201f
2022-02-24 20:29:18 +00:00
Reedy 3b337af58d Namespace extension
Change-Id: I7f64539f1c9c4c03088e28e99f77a9acc503f627
2022-02-06 15:05:09 +00:00
Alexander Vorwerk 57a1d0196b Avoid using WikiPage::factory()
WikiPage::factory() is deprecated since 1.36 and should be replaced
with WikiPageFactory::newFromTitle().

Bug: T297688
Change-Id: I6c754b872c3b60ad724af8c18faacbf7320579fa
2021-12-16 23:56:08 +01:00
Roman Stolar cacfbe6a4f Override ContentHandler::validateSave instead of Content::prepareSave.
Prepare override for TemplateStylesContentHandler, remove usage in TemplateStylesContent.

Bug: T287159
Depends-On: I7f23e6e97b1c7d27a6aaefdb88b19b2fc6e8b3a8
Change-Id: I4d89a5871c8be9101b356dafe68fcbc0cf69f6ee
2021-11-04 13:51:27 +02:00
libraryupgrader fc53ceddcb build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: I49c9642f0fd7782ee739c4a6943a1567f4da8c4d
2021-07-24 02:37:32 +00:00
DannyS712 3d76ede23e Use WikiPage::doUserEditContent() instead of ::doEditContent()
::doUserEditContent() is available since 1.36 as a replacement
for ::doEditContent(), which has been deprecated. Bump the
required version of MediaWiki to 1.36 accordingly.

Bug: T255507
Change-Id: I5d19b24031872105a27e886242c8d580ad278354
2021-06-24 05:59:12 +00:00
libraryupgrader b2ee2313c3 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I0105b425acd5e65b15c789015cdc9144a2d4f8f1
2021-05-04 09:54:28 +00:00
Umherirrender af68773fd1 build: Swap deprecated @codingStandardsIgnore to phpcs:ignore
Bug: T278594
Change-Id: I356955fd31ffa77f8527212a23ddb829941b9505
2021-03-27 00:59:00 +01:00
C. Scott Ananian ef286c1cb7 Replace use of Parser::$mPreprocessor, deprecated in 1.35
This code was a valiant but futile attempt to break a cyclic reference
cycle, copied no doubt from similar code in
tests/phpunit/includes/parser/TagHooksTest.php in core.  However,
there are other cyclic references to Parser, including in StripState,
and unit test code shouldn't really be trying to optimize for memory
usage in any case.

Bug: T275160
Change-Id: I0917290d4ade8675b2d0eac17a22682c9c1b4a85
2021-02-19 12:36:35 -05:00
C. Scott Ananian 2c3e8a8097 Replace use of Parser::$mTagHooks, deprecated in 1.35
The replacement, Parser::getTags(), has been in MediaWiki for over a decade
(since sometime before 1.11).

Bug: T275160
Change-Id: Ib708e3f84aa871de84aa56561c875f4a85bb000c
2021-02-18 17:23:22 -05:00
Reedy 24cb62e044 Update use of css-sanitizer classes for PHP 8.0 compat
Bug: T268862
Depends-On: Ia33f51d54f0e0f51249c999c2bd6a0091aac0b66
Change-Id: I13ad3abe70b693886a79ab37c64f34e0113e9071
2021-01-08 19:03:26 +00:00
Thiemo Kreuz 1c0687c850 Fix wrapper="…" failing for more complex selectors
For example, <templatestyles wrapper="a[href]" /> fails with an
InvalidArgumentException very late in the process, long after
the actual validation in TemplateStylesHooks::validateExtraWrapper()
was done. This happens because validateExtraWrapper() works on a
proper tree (where the [href] from the example is a nested object),
but flattens this tree in the end via toTokenArray(). This
flattened array ends in StyleRuleSanitizer::doSanitize() where it
is added to a ComponentValueList – which expects a tree.

The only change in this patch is that the object structure is not
flattened any more. That's all.

Bug: T258093
Change-Id: I5dc04611f91fe672da706f31fa8d0c254e3123d3
2020-10-15 06:51:21 +00:00
DannyS712 c74a26d111 Use RevisionRecordCallback in ParserOptions, require MW 1.35+
Bug: T249384
Change-Id: I36b7a57278f9c32040180fc885827731a2d94098
2020-06-03 03:12:20 +00:00
DannyS712 9f3832efdf Revert "Remove use of WikiPage::doEditContent"
This reverts commit eb94a40c3e.

Reason for revert: autopatrol status wasn't included in the
use of PageUpdater, revert for now and reapply properly with
autopatrol later.

Bug: T252179
Change-Id: I38e29e607bc01146ccab00ef8e10d59b769e4044
2020-05-08 00:16:42 +00:00
DannyS712 eb94a40c3e Remove use of WikiPage::doEditContent
Bug: T250638
Change-Id: Ie2ee283ba34db120586469b5d34c3840297e134b
2020-04-20 00:31:43 +00:00
C. Scott Ananian eb0babef80 Don't use deprecated $wgParserConf global
The modern way to create a Parser object is to use a ParserFactory.

Change-Id: I97d58750c91b06eeca5d810509becdf53a39cc95
2020-04-16 14:39:33 -04:00
peter-ovchyn 08ce0c613e Remove onParserAfterTidy hood as tidy is dead
Bug: T244055
Change-Id: I7afa31c6a542bfafbd50a55a1e79058074bf4906
2020-02-21 21:59:16 +02:00
James D. Forrester de4ea4d91a build: Upgrade mediawiki-codesniffer to v28.0.0
Change-Id: I703c20b1a3f5687a8488a30a57b1d14d79336be0
2019-10-15 15:59:23 -07:00
Max Semenik c874b0c4bc @expectedException is deprecated
Bug: T234597
Change-Id: Ieeb352cb37822b9eabc5179d7a30fb137070639b
2019-10-11 19:39:58 -07:00
Amir Sarabadani 84591b3505 Make unit tests follow the new structure
Change-Id: Iad546e528c2df86866afcf2f49df2c7209563bc7
2019-07-21 23:05:08 +02:00
James D. Forrester 169e618357 tests: Remove newlines from tests to make pass(?!)
Change-Id: Ib7f4252e4b399edcd5845aa31c60df494a8d8c3e
2019-04-12 14:58:20 -07:00
MGChecker f121c39613 Allow extensions to register additional namespaces in extension.json
Extensions can register additional namespaces by setting the
"TemplateStylesNamespaces" attribte in their extension.json. This change is
analogous to Ia5d34cb78fa6af.

There isn't really a simpler way to do this here, as the config setting uses
namespaces as keys, while the attribute is using them as values. Furthermore,
keys with falsey values are ignored in the config setting, and attributes can't
use the same setting architecture, as array_merge_recursive doesn't maintain
numeric keys.

Bug: T200914
Depends-On: I9e62a02ed2044c847e9ab2dcdfab094001f88986
Change-Id: I2fa9b822ee39bcc5f95a293c8c4aad4d53ede30a
2019-01-12 11:40:58 -08:00
Brad Jorsch f7bf5a4e23 Add "wrapper" attribute to <templatestyles/>
The wrapper attribute may contain an extra CSS simple selector to
include when prefixing. For example, including a template as
<templatestyles src="..." wrapper="div.my-template"/> would transform

 .foo .bar { color:red; }

into

 .mw-parser-output div.my-template .foo .bar{color:red}

This can allow particular templates to opt in to the "styles are scoped
to the template itself" model that was desired by some when
TemplateStyles was being designed; the driving use case in the linked
task is doing so for the benefit of side-by-side comparisons of the
current and sandboxed versions of a template.

Bug: T200441
Change-Id: If49d4c5be31feca95abd21452238fd10ab1916b1
2018-10-17 14:17:59 -04:00
Kunal Mehta da954dd045 Don't use stashMwGlobals()
Being deprecated in I23d77398e4.

Change-Id: I9315111c86599472887c616658ac25ba7979d340
2018-10-07 22:02:48 -07:00
Gergő Tisza 17756c44b2
Hoist selectors for html and body element
Bug: T197617
Depends-On: Iac00198495cf08dec034f45100937df0f6cb1590
Change-Id: I5dd85d12eb77c70c1632974561c4cad8636fad1d
2018-08-24 22:16:17 +02:00
Gergő Tisza 3d6444fc77 Fix <p> wrappers in unit tests
Updates expected test results for Ide4005842c.

Bug: T186965
Change-Id: Iff92e6cd0a88d4f595148f837d892b7123b12b29
2018-03-03 23:24:21 +00:00
libraryupgrader a88b7c164f build: Updating mediawiki/mediawiki-codesniffer to 16.0.0
The following sniffs now pass and were enabled:
* MediaWiki.Files.ClassMatchesFilename.NotMatch

Change-Id: I4b4f7577107b869789479671e74b1fa7329979aa
2018-02-15 14:32:27 +00:00
jenkins-bot 292a347325 Merge "Swap MediaWiki\quietCall -> Wikimedia\quietCall" 2018-02-11 14:54:15 +00:00
Reedy 37c5b722d2 Swap MediaWiki\quietCall -> Wikimedia\quietCall
Bug: T182273
Change-Id: I9d5028ff04d5a8904462a8b6b0819d1974ee06a7
2018-02-11 06:03:39 +00:00
Brad Jorsch 164b8861d8 Deduplicate embedded style rules
Use the facility added in core change I055abdf4d to deduplicate the
embedded style rules.

Bug: T168333
Change-Id: I98c6d5ca4b474de8826b19355f15a5230aef5650
Depends-On: I055abdf4d73ec65771eaa4fe0999ec907c831568
2018-02-11 05:50:55 +00:00
Brad Jorsch f99d171c80 Fix coverage
* Fix test for TemplateStylesFontFaceAtRuleSanitizer so it's actually run
* Hack up a broken Sanitizer to test a code path in
  TemplateStylesContent::sanitize() that handles such things.
* Ignore an InvalidArgumentException in TemplateStylesContent::processError()
  that's not worth checking. User input can't hit that, only logic bugs.
* Ignore TemplateStylesHooks::getConfig(), it's tested but gets called
  before PHPUnit starts counting.
* Test TemplateStylesHooksTest::onCodeEditorGetPageLanguage()
* Test $wgTemplateStylesDisable
* Test a back-compat code path in TemplateStylesHooks::handleTag().

Change-Id: I7078e5a353a624aa53fe72de7990b93a77b44cf6
2018-02-05 22:36:58 -05:00
Kunal Mehta 5ba45a396b Add @covers tags
Change-Id: Ie87849bc9dcc0b26363c9475930c967841e6a7f7
2018-02-05 18:19:30 -08:00
Brad Jorsch 8f3d6ce2d1 Use 'unwrap' post-cache transform instead of setWrapOutputClass( false )
To reduce parser cache fragmentation, core is deprecating
$parserOptions->setWrapOutputClass( false ) in favor of
$parserOutput->getText( [ 'unwrap' => true ] );

Change-Id: I23a26ba0dfbe83007cd40e97d71a2139a5ecddc7
Depends-On: Iba16e78c41be992467101e7d83e9c3134765b101
2017-12-22 13:43:15 -05:00
Max Semenik dbdd8dbc85 Don't skip tests if the hook is not present
This just hides the error if something's broken with extension
registration because skipped tests don't result in a failed suite.
Instead, explode in everybody's eyes to make it clear there's a
problem.

Change-Id: I2f1e80a1fa4b99d857671c9d1061d34449764f01
2017-11-14 14:14:53 -08:00
Max Semenik 2db83c5d07 Type annotations for some tests
Also fix one function's case.

Change-Id: Ibe1750e6cfed593304e027d4eda7609a73980e62
2017-11-14 14:14:24 -08:00
Max Semenik cec2c6db0c Fix tests
Change-Id: I07d9271511e279cd0e12910673848654e6ff5eef
2017-11-14 13:55:06 -08:00
Kunal Mehta 612524a641 build: Updating mediawiki/mediawiki-codesniffer to 0.9.0
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.FunctionComment.Missing.Protected
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: Ic998e3f2a791bf987f826d6dd0e92a8de24be5b7
2017-06-20 00:22:54 -07:00
Brad Jorsch 5fd77aa0d7 Update css-sanitizer to v1.0.2
Also fold a unit test into the normal function since we don't have to
have two valid responses based on css-sanitizer version.

Change-Id: I107c8b911781924ce9cc0730257243b9cb1592a6
2017-06-13 17:09:48 -04:00
Brad Jorsch b04bd96f58 SECURITY: Reject stylesheets containing "</style"
Premature closing of the style block === HTML injection vector.

Bug: T167812
Change-Id: I34c5f200c689a56d340bce70ffebbf58d27b499e
2017-06-13 11:52:07 -04:00