Skip to content

Commit 8ef842d

Browse files
committed
Merge branch '6.0-dev' into 6.1/maint/upmerge-260106
2 parents a5ed80c + 495f8fd commit 8ef842d

File tree

3 files changed

+39
-3
lines changed

3 files changed

+39
-3
lines changed

libraries/src/Filter/InputFilter.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
namespace Joomla\CMS\Filter;
1111

12+
use enshrined\svgSanitize\Sanitizer;
1213
use Joomla\CMS\String\PunycodeHelper;
1314
use Joomla\Filter\InputFilter as BaseInputFilter;
1415

@@ -492,4 +493,39 @@ protected function stripUSC($source)
492493

493494
return preg_replace('/[\xF0-\xF7].../s', "\xE2\xAF\x91", $source);
494495
}
496+
497+
/**
498+
* Internal method to strip a tag of disallowed attributes - extended to filter SVG content
499+
*
500+
* @param array $attrSet Array of attribute pairs to filter
501+
*
502+
* @return array Filtered array of attribute pairs
503+
*
504+
* @since 6.0.2
505+
*/
506+
protected function cleanAttributes(array $attrSet)
507+
{
508+
// Do the heavy lifting in the upstream library
509+
$attrSet = parent::cleanAttributes($attrSet);
510+
511+
// Decode and check base64-encoded svgs
512+
return array_map(
513+
function ($attribute) {
514+
// Check for presence of relevant tags
515+
if (!preg_match('/"data:.*svg.*;base64,(.*)"/U', $attribute, $matches)) {
516+
return $attribute;
517+
}
518+
519+
// Extract SVG
520+
$svg = base64_decode($matches[1], true);
521+
522+
// Sanitize svg
523+
$sanitizer = new Sanitizer();
524+
525+
// Replace content
526+
return str_replace($matches[1], base64_encode($sanitizer->sanitize($svg)), $attribute);
527+
},
528+
$attrSet,
529+
);
530+
}
495531
}

plugins/content/pagebreak/tmpl/toc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<?php $class = $listItem->active ? ' active' : ''; ?>
2626
<li class="py-1">
2727
<a href="<?php echo Route::_($listItem->link); ?>" class="toclink<?php echo $class; ?>">
28-
<?php echo $listItem->title; ?>
28+
<?php echo htmlspecialchars($listItem->title, ENT_QUOTES, 'UTF-8'); ?>
2929
</a>
3030
</li>
3131
<?php endforeach; ?>

plugins/content/pagenavigation/tmpl/default.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<span class="visually-hidden">
2929
<?php echo Text::sprintf('JPREVIOUS_TITLE', htmlspecialchars($rows[$location - 1]->title)); ?>
3030
</span>
31-
<?php echo '<span class="icon-chevron-' . $direction . '" aria-hidden="true"></span> <span aria-hidden="true">' . $row->prev_label . '</span>'; ?>
31+
<?php echo '<span class="icon-chevron-' . $direction . '" aria-hidden="true"></span> <span aria-hidden="true">' . htmlspecialchars($row->prev_label) . '</span>'; ?>
3232
</a>
3333
<?php endif; ?>
3434
<?php if ($row->next) :
@@ -37,7 +37,7 @@
3737
<span class="visually-hidden">
3838
<?php echo Text::sprintf('JNEXT_TITLE', htmlspecialchars($rows[$location + 1]->title)); ?>
3939
</span>
40-
<?php echo '<span aria-hidden="true">' . $row->next_label . '</span> <span class="icon-chevron-' . $direction . '" aria-hidden="true"></span>'; ?>
40+
<?php echo '<span aria-hidden="true">' . htmlspecialchars($row->next_label) . '</span> <span class="icon-chevron-' . $direction . '" aria-hidden="true"></span>'; ?>
4141
</a>
4242
<?php endif; ?>
4343
</span>

0 commit comments

Comments
 (0)