Skip to content

Commit 19f78db

Browse files
committed
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
1 parent a33dbcb commit 19f78db

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

app/Util/HtmlDescriptionFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HtmlDescriptionFilter
2020
*/
2121
protected static array $allowedAttrsByElements = [
2222
'p' => [],
23-
'a' => ['href', 'title'],
23+
'a' => ['href', 'title', 'target'],
2424
'ol' => [],
2525
'ul' => [],
2626
'li' => [],

resources/js/wysiwyg/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export function buildForInput(options) {
348348
toolbar: 'bold italic link bullist numlist',
349349
content_style: getContentStyle(options),
350350
file_picker_types: 'file',
351-
valid_elements: 'p,a[href|title],ol,ul,li,strong,em,br',
351+
valid_elements: 'p,a[href|title|target],ol,ul,li,strong,em,br',
352352
file_picker_callback: filePickerCallback,
353353
init_instance_callback(editor) {
354354
addCustomHeadContent(editor.getDoc());

tests/Entity/BookTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ public function test_description_limited_to_specific_html()
266266
{
267267
$book = $this->entities->book();
268268

269-
$input = '<h1>Test</h1><p id="abc" href="beans">Content<a href="#cat" data-a="b">a</a><section>Hello</section></p>';
270-
$expected = '<p>Content<a href="#cat">a</a></p>';
269+
$input = '<h1>Test</h1><p id="abc" href="beans">Content<a href="#cat" target="_blank" data-a="b">a</a><section>Hello</section></p>';
270+
$expected = '<p>Content<a href="#cat" target="_blank">a</a></p>';
271271

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

0 commit comments

Comments
 (0)