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
The handleTag() method is used for parsing `<templatestyles>` in
wikitext. The result of that should not vary by unregistered variables
such as ResourceLoader's `debug` parameter, or user cookies, which
seem likely to cause cache poisoning.
Bug: T36738
Change-Id: I85ab7bc694858bc8e7fe2f3cc79197ff4f2d1c38
After removable of DeprecationHelper from Parser.php with
I4ff100136a777974f7206f599422589d51f02b88 the __set function is gone,
which indicates phan that undeclared properties are possible
Depends-On: I56397a085226538a8156e0e7a195db463240624c
Change-Id: I1cef45d5b0caff53ee126a55825dc85d8a276b43
This adds a config option so that the src attribute of the <templatestyles> tag can be set to default namespace other than Template.
Bug: T290250
Change-Id: Iec4f5d630d025e0bacba05d40cd74fc9312fcae2
* $wgTemplateStylesPropertyBlacklist is now $wgTemplateStylesDisallowedProperties
* $wgTemplateStylesAtRuleBlacklist is now $wgTemplateStylesDisallowedAtRules
Bug: T277962
Change-Id: I2eb120f5c52db1ea9c49bcaf04955771987c1d62
The replacement, Parser::getStripState(), was added to MediaWiki in
1.34. This extension already requires MediaWiki >= 1.35.
Bug: T275160
Change-Id: I429da35ca4e276c852b8d6ee102ff19f742c22c0
This is cached anyway in the ConfigFactory.
This patch also includes a few very minor cleanups in the
same file.
Change-Id: Iec44dae1d6a69e0f28d62f875a22f30f8b10cf78
A token is a component value, but not all component values are tokens.
Follows up I5dc04611f.
Bug: T258093
Change-Id: I2292a5dbedf1607f9ad25d2b4021a225a202d407
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
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
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
Having a different ParserOptions for each content model isn't feasible
in an MCR world. And the only thing using this was Wikibase, which has
been fixed to do what it needs in a different way.
Bug: T194263
Change-Id: Ia95f3e2c1ea944366ff9a478c3c86f8565023394
Depends-On: I01373b29ee25fa9346c6b0317155be4ccdc8c515
Two tracking categories are added:
* A category to track stylesheets with errors. While it's usually not
possible to save a stylesheet with errors, it can happen if a
server-side change makes formerly-valid CSS become invalid.
* A category to track pages displaying errors from incorrect use of
the <templatestyles/> tag.
Bug: T195676
Change-Id: I123679d4bffe36cb28aca1688c052470027ea2a8
SPDX released version 3 of their license list (<https://spdx.org/licenses/>),
which changed the FSF licenses to explicitly end in -only or -or-later
instead of relying on an easy to miss + symbol.
Bug: T183858
Change-Id: Ic9accb2eb34bc32d455f48dfe81a91d23a2d5f5e
Use the facility added in core change I055abdf4d to deduplicate the
embedded style rules.
Bug: T168333
Change-Id: I98c6d5ca4b474de8826b19355f15a5230aef5650
Depends-On: I055abdf4d73ec65771eaa4fe0999ec907c831568
* 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