Skip to content

Commit

Permalink
fix(link): object replacement character sanitization #5679 (#5887)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Alex Casillas <[email protected]>
  • Loading branch information
alexvcasillas and Alex Casillas authored Nov 29, 2024
1 parent f49ef7c commit 2acf260
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/unlucky-ravens-build.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion packages/extension-link/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2acf260

Please sign in to comment.