Skip to content

Commit 4f2c7ca

Browse files
osnardrvogel
andauthored
Explicitly declare HtmlArmor exceptions (#20)
* Explicitly state HtmlArmor excluded fields ERM29427 ERM29429 ERM29430 * Remove defaults * Bump version * Apply HtmlArmor for rendered subcomponent html Co-authored-by: rvogel <vogel@hallowelt.biz>
1 parent 18d8610 commit 4f2c7ca

36 files changed

+103
-29
lines changed

bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
return;
99
}
1010

11-
define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONUSERINTERFACE_VERSION', '3.0.4' );
11+
define( 'MWSTAKE_MEDIAWIKI_COMPONENT_COMMONUSERINTERFACE_VERSION', '3.0.5' );
1212

1313
MWStake\MediaWiki\ComponentLoader\Bootstrapper::getInstance()
1414
->register( 'commonuserinterface', function () {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<button {{#id}}id="{{.}}" {{/id}}class="btn{{#class}} {{.}}{{/class}}" type="button"{{#disabled}} disabled{{/disabled}}>
2-
<span class="visually-hidden">{{{aria-label}}}</span>
2+
<span class="visually-hidden">{{aria-label}}</span>
33
{{{text}}}
44
</button>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<img src="{{src}}" class="card-img-{{type}}{{#class}} {{.}}{{/class}}" alt="{{alt}}">
1+
<img src="{{src}}" class="card-img-{{type}}{{#class}} {{.}}{{/class}}" alt="{{alt}}" />

resources/templates/dropdown-split-link.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="dropdown{{#cnt-class}} {{.}}{{/cnt-class}}">
22
<div class="btn-group{{#btn-group-class}} {{.}}{{/btn-group-class}}">
33
<a {{#btn-class}}class="{{.}}"{{/btn-class}}{{#id}} id="{{.}}"{{/id}} title="{{btn-title}}"{{#btn-data}} {{{.}}}{{/btn-data}} aria-haspopup="true" aria-label="{{btn-aria-label}}"{{#btn-disabled}} disabled{{/btn-disabled}} href="{{btn-href}}">
4-
{{{btn-text}}}
4+
{{btn-text}}
55
</a>
66
<a class="dropdown-toggle{{#split-btn-class}} {{.}}{{/split-btn-class}}"{{#id}} id="{{.}}-menu-btn"{{/id}} title="{{split-btn-title}}"{{#split-btn-data}} {{{.}}}{{/split-btn-data}} data-bs-toggle="dropdown" aria-haspopup="true" aria-label="{{split-btn-aria-label}}" aria-expanded="false" aria-controls="{{id}}-menu"{{#split-btn-disabled}} disabled{{/split-btn-disabled}} href="">
77
</a>

src/IDropdownIconSplitButton.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getSplitButtonClasses() : array;
3737
public function getMenuClasses() : array;
3838

3939
/**
40-
* @return Message
40+
* @return array
4141
*/
4242
public function getIconClasses() : array;
4343

src/Renderer/Accordion.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getTemplatePathname() : string {
4343
* @inheritDoc
4444
*/
4545
protected function getHtmlArmorExcludedFields() {
46-
return [ 'header-text', 'body' ];
46+
return [ 'id' ];
4747
}
4848

4949
}

src/Renderer/Badge.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ public function getRendererDataTreeNode( $component, $subComponentNodes ) : arra
5151
public function getTemplatePathname() : string {
5252
return $this->templateBasePath . '/badge.mustache';
5353
}
54+
55+
/**
56+
* @inheritDoc
57+
*/
58+
protected function getHtmlArmorExcludedFields() {
59+
return [ 'class' ];
60+
}
5461
}

src/Renderer/Button.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,11 @@ public function getTemplatePathname() : string {
6666
return $this->templateBasePath . '/button.mustache';
6767
}
6868

69+
/**
70+
* @inheritDoc
71+
*/
72+
protected function getHtmlArmorExcludedFields() {
73+
return [ 'id', 'class', 'disabled', 'aria-label' ];
74+
}
75+
6976
}

src/Renderer/ButtonGroup.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,11 @@ public function getRendererDataTreeNode( $component, $subComponentNodes ) : arra
6464
public function getTemplatePathname() : string {
6565
return $this->templateBasePath . '/button-group.mustache';
6666
}
67+
68+
/**
69+
* @inheritDoc
70+
*/
71+
protected function getHtmlArmorExcludedFields() {
72+
return [ 'class', 'role', 'aria-label' ];
73+
}
6774
}

src/Renderer/Card.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use MWStake\MediaWiki\Component\CommonUserInterface\ICard;
7+
use MWStake\MediaWiki\Component\CommonUserInterface\IComponent;
78

89
class Card extends RendererBase {
910

@@ -47,6 +48,6 @@ public function getRendererDataTreeNode( $component, $subComponentNodes ) : arra
4748
* @inheritDoc
4849
*/
4950
protected function getHtmlArmorExcludedFields() {
50-
return [ 'body' ];
51+
return [ 'id', 'class' ];
5152
}
5253
}

0 commit comments

Comments
 (0)