diff --git a/src/Forms/HTMLEditor/HTMLEditorSanitiser.php b/src/Forms/HTMLEditor/HTMLEditorSanitiser.php index fa23c476b..c056bca10 100644 --- a/src/Forms/HTMLEditor/HTMLEditorSanitiser.php +++ b/src/Forms/HTMLEditor/HTMLEditorSanitiser.php @@ -343,7 +343,7 @@ class HTMLEditorSanitiser } // Matches "javascript:" with any arbitrary linebreaks inbetween the characters. - $regex = '/^\s*' . implode('\s*', str_split('javascript:')) . '/i'; + $regex = '#^\s*(' . implode('\s*', str_split('javascript:')) . '|' . implode('\s*', str_split('data:text/html;')) . ')#i'; // Strip out javascript execution in href or src attributes. foreach (['src', 'href', 'data'] as $dangerAttribute) { if ($el->hasAttribute($dangerAttribute)) { diff --git a/src/Forms/HTMLEditor/TinyMCEConfig.php b/src/Forms/HTMLEditor/TinyMCEConfig.php index eed09760a..297554024 100644 --- a/src/Forms/HTMLEditor/TinyMCEConfig.php +++ b/src/Forms/HTMLEditor/TinyMCEConfig.php @@ -322,7 +322,8 @@ class TinyMCEConfig extends HTMLEditorConfig implements i18nEntityProvider . "-div[id|dir|class|align|style],-span[class|align|style],-pre[class|align],address[class|align]," . "-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style]," . "-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class]," - . "dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir]," + . "dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],", + 'convert_unsafe_embeds' => true, // SS-2024-001 ]; protected $settings = []; diff --git a/tests/php/Forms/HTMLEditor/HTMLEditorSanitiserTest.php b/tests/php/Forms/HTMLEditor/HTMLEditorSanitiserTest.php index 6e68b39d6..ee3d99802 100644 --- a/tests/php/Forms/HTMLEditor/HTMLEditorSanitiserTest.php +++ b/tests/php/Forms/HTMLEditor/HTMLEditorSanitiserTest.php @@ -120,7 +120,31 @@ class HTMLEditorSanitiserTest extends FunctionalTest 'object[data]', '', '', - 'Object with dangerous content in data attribute is completely removed' + 'Object with dangerous javascript content in data attribute is completely removed' + ], + [ + 'object[data]', + '', + '', + 'Object with dangerous javascript content in data attribute with quotes is completely removed' + ], + [ + 'object[data]', + '', + '', + 'Object with dangerous html content in data attribute is completely removed' + ], + [ + 'object[data]', + '