File tree Expand file tree Collapse file tree 3 files changed +39
-3
lines changed
Expand file tree Collapse file tree 3 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 99
1010namespace Joomla \CMS \Filter ;
1111
12+ use enshrined \svgSanitize \Sanitizer ;
1213use Joomla \CMS \String \PunycodeHelper ;
1314use 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}
Original file line number Diff line number Diff line change 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 ; ?>
Original file line number Diff line number Diff line change 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 ) :
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>
You can’t perform that action at this time.
0 commit comments