Update ParsedownExtra to use mb_encode_numericentity for safer HTML

encoding
This commit is contained in:
Ruben 2026-01-16 22:03:31 +01:00
parent 7b5d07a88d
commit 0901d6324c

View file

@ -625,7 +625,7 @@ class ParsedownExtra extends Parsedown
$DOMDocument = new DOMDocument; $DOMDocument = new DOMDocument;
# http://stackoverflow.com/q/11309194/200145 # http://stackoverflow.com/q/11309194/200145
$elementMarkup = mb_convert_encoding($elementMarkup, 'HTML-ENTITIES', 'UTF-8'); $elementMarkup = mb_encode_numericentity($elementMarkup, [0x80, 0x10FFFF, 0, ~0], 'UTF-8');
# http://stackoverflow.com/q/4879946/200145 # http://stackoverflow.com/q/4879946/200145
$DOMDocument->loadHTML($elementMarkup); $DOMDocument->loadHTML($elementMarkup);
@ -683,4 +683,4 @@ class ParsedownExtra extends Parsedown
# #
protected $regexAttribute = '(?:[#.][-\w]+[ ]*)'; protected $regexAttribute = '(?:[#.][-\w]+[ ]*)';
} }