From 19f78dbe6c1198a0b7072340d1422efaf0cd8bd0 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 3 Apr 2024 16:46:53 +0100 Subject: [PATCH] WYSIWYG descriptions: Allowed anchor target attrs Allowed since this is a control in the editor UI, but would previously be stripped by editor config & server-side filtering. For #4925 --- app/Util/HtmlDescriptionFilter.php | 2 +- resources/js/wysiwyg/config.js | 2 +- tests/Entity/BookTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/Util/HtmlDescriptionFilter.php b/app/Util/HtmlDescriptionFilter.php index 7287586d1..cb091b869 100644 --- a/app/Util/HtmlDescriptionFilter.php +++ b/app/Util/HtmlDescriptionFilter.php @@ -20,7 +20,7 @@ class HtmlDescriptionFilter */ protected static array $allowedAttrsByElements = [ 'p' => [], - 'a' => ['href', 'title'], + 'a' => ['href', 'title', 'target'], 'ol' => [], 'ul' => [], 'li' => [], diff --git a/resources/js/wysiwyg/config.js b/resources/js/wysiwyg/config.js index e5a780d18..1666aa500 100644 --- a/resources/js/wysiwyg/config.js +++ b/resources/js/wysiwyg/config.js @@ -348,7 +348,7 @@ export function buildForInput(options) { toolbar: 'bold italic link bullist numlist', content_style: getContentStyle(options), file_picker_types: 'file', - valid_elements: 'p,a[href|title],ol,ul,li,strong,em,br', + valid_elements: 'p,a[href|title|target],ol,ul,li,strong,em,br', file_picker_callback: filePickerCallback, init_instance_callback(editor) { addCustomHeadContent(editor.getDoc()); diff --git a/tests/Entity/BookTest.php b/tests/Entity/BookTest.php index 04dff293f..51bf65d10 100644 --- a/tests/Entity/BookTest.php +++ b/tests/Entity/BookTest.php @@ -266,8 +266,8 @@ class BookTest extends TestCase { $book = $this->entities->book(); - $input = '

Test

Contenta

Hello

'; - $expected = '

Contenta

'; + $input = '

Test

Contenta

Hello

'; + $expected = '

Contenta

'; $this->asEditor()->put($book->getUrl(), [ 'name' => $book->name,