NOW MANAGED ON CODEBERG
Content filter: Allowed custom diagram attribute in allow-list
Dan Browna8d96fd3892c
diff --git a/app/Util/ConfiguredHtmlPurifier.php b/app/Util/ConfiguredHtmlPurifier.phpindex 87580da8b..ab2333388 100644--- a/app/Util/ConfiguredHtmlPurifier.php+++ b/app/Util/ConfiguredHtmlPurifier.php@@ -134,6 +134,13 @@ class ConfiguredHtmlPurifier'value' => 'Text',]);++ // Allow the drawio-diagram attribute on div elements+ $definition->addAttribute(+ 'div',+ 'drawio-diagram',+ 'Number',+ );}public function purify(string $html): stringdiff --git a/tests/Entity/PageContentFilteringTest.php b/tests/Entity/PageContentFilteringTest.phpindex c048c09dc..4f77e0633 100644--- a/tests/Entity/PageContentFilteringTest.php+++ b/tests/Entity/PageContentFilteringTest.php@@ -463,6 +463,7 @@ HTML;'<div style="position:absolute;left:0;color:#00FFEE;">Hello!</div>' => '<div style="color:#00FFEE;">Hello!</div>','<div style="background:#FF0000;left:0;color:#00FFEE;">Hello!</div>' => '<div style="background:#FF0000;color:#00FFEE;">Hello!</div>','<div style="color:#00FFEE;">Hello!<style>testinghello!</style></div>' => '<div style="color:#00FFEE;">Hello!</div>',+ '<div drawio-diagram="5332" another-attr="cat">Hello!</div>' => '<div drawio-diagram="5332">Hello!</div>',];config()->set('app.content_filtering', 'a');