Commit graph

36 commits

Author SHA1 Message Date
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 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
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
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
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
Max Semenik c874b0c4bc @expectedException is deprecated
Bug: T234597
Change-Id: Ieeb352cb37822b9eabc5179d7a30fb137070639b
2019-10-11 19:39:58 -07: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
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
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
Brad Jorsch b301a30abf Use wikimedia/css-sanitizer, and rewrite the hooking
wikimedia/css-sanitizer provides a real CSS parser, which should be
safer than poking at things with regular expressions.

Instead of the strange hybrid model that tried to both process inline
CSS and save CSS when the template is saved, it now looks for
<templatestyles src="Title" /> during the parse to do all the
transclusion of styles.

The output method is "<style> tags in the body", pending someone
implementing T160563.

It now also registers a "sanitized-css" content model, which should pick
up the CSS syntax highlighting and will validate the submitted CSS on
submit and prevent a save if it's not valid.

This patch also takes advantage of LGPL-2.x § 3 to relicense the
extension as GPL-2.0+, although at this point none of the LGPL code
remains anyway.

Bug: T133408
Bug: T136054
Bug: T135788
Bug: T135789
Change-Id: I993e6f18d32a43aac8398743133d227b05133bbd
Depends-On: If4eb5bf71f94fa366ec4eddb6964e8f4df6b824a
2017-06-07 15:14:09 +00:00