fix(link): object replacement character sanitization #5679 (#5887)
Some checks are pending
build / lint (20) (push) Waiting to run
build / test (20, map[name:Demos/Examples spec:./demos/src/Examples/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Experiments spec:./demos/src/Experiments/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Extensions spec:./demos/src/Extensions/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/GuideContent spec:./demos/src/GuideContent/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/GuideGettingStarted spec:./demos/src/GuideGettingStarted/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Marks spec:./demos/src/Marks/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Demos/Nodes spec:./demos/src/Nodes/**/*.spec.{js,ts}]) (push) Waiting to run
build / test (20, map[name:Integration spec:./tests/cypress/integration/**/*.spec.{js,ts}]) (push) Waiting to run
build / build (20) (push) Blocked by required conditions
Publish / Release (20) (push) Waiting to run

---------

Co-authored-by: Alex Casillas <alexvcasilas@gmail.com>
This commit is contained in:
Alex Casillas 2024-11-29 12:38:36 +01:00 committed by GitHub
parent f49ef7cabb
commit 2acf260f85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/extension-link": patch
---
fix: #5679 - perform string sanitization to remove unwanted "object replacement characters" from the before performing link detection

View File

@ -351,7 +351,12 @@ export const Link = Mark.create<LinkOptions>({
if (text) {
const { protocols, defaultProtocol } = this.options
const links = find(text).filter(
// Prosemirror replaces zero-width non-joiner characters
// with Object Replacement Character from unicode.
// Therefore, linkifyjs does not recognize the
// link properly. We replace these characters
// with regular spaces to fix this issue.
const links = find(text.replaceAll('\uFFFC', ' ')).filter(
item => item.isLink
&& this.options.isAllowedUri(item.value, {
defaultValidate: href => !!isAllowedUri(href, protocols),