Skip to content

Commit

Permalink
WYSIWYG descriptions: Allowed anchor target attrs
Browse files Browse the repository at this point in the history
Allowed since this is a control in the editor UI, but would previously
be stripped by editor config & server-side filtering.
For #4925
  • Loading branch information
ssddanbrown committed Apr 3, 2024
1 parent a33dbcb commit 19f78db
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Util/HtmlDescriptionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HtmlDescriptionFilter
*/
protected static array $allowedAttrsByElements = [
'p' => [],
'a' => ['href', 'title'],
'a' => ['href', 'title', 'target'],
'ol' => [],
'ul' => [],
'li' => [],
Expand Down
2 changes: 1 addition & 1 deletion resources/js/wysiwyg/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions tests/Entity/BookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ public function test_description_limited_to_specific_html()
{
$book = $this->entities->book();

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

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

0 comments on commit 19f78db

Please sign in to comment.