Skip to content

Commit e04cef8

Browse files
jenkins-botGerrit Code Review
authored andcommitted
Merge "Specify htmlspecialchars() flags"
2 parents 836b9b6 + 678b865 commit e04cef8

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/includes/Formatters/WikibaseValueFormatterBuilders.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ private function isHtmlFormat( $format ) {
211211
private function escapeValueFormatter( $format, ValueFormatter $formatter ) {
212212
switch ( $this->snakFormat->getBaseFormat( $format ) ) {
213213
case SnakFormatter::FORMAT_HTML:
214-
return new EscapingValueFormatter( $formatter, 'htmlspecialchars' );
214+
return new EscapingValueFormatter( $formatter, static function ( string $string ): string {
215+
return htmlspecialchars( $string, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5 );
216+
} );
215217
case SnakFormatter::FORMAT_WIKI:
216218
return new EscapingValueFormatter( $formatter, 'wfEscapeWikiText' );
217219
default:

lib/tests/phpunit/Formatters/WikibaseValueFormatterBuildersTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,14 @@ public function provideNewFormatter() {
451451
SnakFormatter::FORMAT_HTML_VERBOSE,
452452
$this->newFormatterOptions( 'de' ),
453453
new GlobeCoordinateValue( new LatLongValue( -55.755786, 37.25633 ), 0.25 ),
454-
'@^<div><kartographer-html/><div class="wikibase-kartographer-caption">55°45\'S, 37°15\'E</div></div>$@'
454+
'@^<div><kartographer-html/><div class="wikibase-kartographer-caption">55°45&apos;S, 37°15&apos;E</div></div>$@'
455455
],
456456
'coordinate kartographer preview html' => [
457457
'GlobeCoordinate',
458458
SnakFormatter::FORMAT_HTML_VERBOSE_PREVIEW,
459459
$this->newFormatterOptions( 'de' ),
460460
new GlobeCoordinateValue( new LatLongValue( -55.755786, 37.25633 ), 0.25 ),
461-
'@^<div><kartographer-preview-html/><div class="wikibase-kartographer-caption">55°45\'S, 37°15\'E</div></div>$@'
461+
'@^<div><kartographer-preview-html/><div class="wikibase-kartographer-caption">55°45&apos;S, 37°15&apos;E</div></div>$@'
462462
],
463463

464464
// Quantity

0 commit comments

Comments
 (0)