Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Marks/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public function parseHTML()
return false;
}

return null;
return [
'target' => $DOMNode->getAttribute('target') ?: null,
];
},
],
];
Expand Down
11 changes: 7 additions & 4 deletions tests/DOMParser/Marks/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'type' => 'link',
'attrs' => [
'href' => 'https://tiptap.dev',
'target' => null,
],
],
],
Expand Down Expand Up @@ -56,6 +57,7 @@
'attrs' => [
'href' => 'https://tiptap.dev',
'rel' => 'noopener',
'target' => null,
],
],
],
Expand Down Expand Up @@ -86,6 +88,7 @@
'attrs' => [
'href' => 'https://tiptap.dev',
'class' => 'tiptap',
'target' => null,
],
],
],
Expand Down Expand Up @@ -143,10 +146,10 @@ function getInvalidUrls()
return [
// A standard JavaScript protocol
"javascript:alert(window.origin)",

// The protocol is not case sensitive
"jAvAsCrIpT:alert(window.origin)",

// Characters \x01-\x20 are allowed before the protocol
"\x00javascript:alert(window.origin)",
"\x01javascript:alert(window.origin)",
Expand Down Expand Up @@ -180,12 +183,12 @@ function getInvalidUrls()
"\x1djavascript:alert(window.origin)",
"\x1ejavascript:alert(window.origin)",
"\x1fjavascript:alert(window.origin)",

// Characters \x09,\x0a,\x0d are allowed inside the protocol
"java\x09script:alert(window.origin)",
"java\x0ascript:alert(window.origin)",
"java\x0dscript:alert(window.origin)",

// Characters \x09,\x0a,\x0d are allowed after protocol name before the colon
"javascript\x09:alert(window.origin)",
"javascript\x0a:alert(window.origin)",
Expand Down