Skip to content

HTMLAnchorElement throws with malformed URLs #316

@Soxasora

Description

@Soxasora

We use LinkeDOM with Lexical to export HTML from an EditorState on the backend.
The PR #204 introduced decodeURI on get href() and get download() to fix double encoding of already encoded characters but this causes every malformed URL to throw URIError.

For example, a LinkNode in Lexical can be anything, can also have % as URL. When it comes to converting the LinkNode to an HTMLAnchorElement via LinkeDOM, decodeURI throws and the whole HTML generation fails.

It's not a real problem, I can sanitize these URLs myself, but I wanted to report this anyway. Thanks a lot for everything, LinkeDOM is really fast!

Logs

URIError: URI malformed
at decodeURI (<anonymous>)
at set href (/var/app/current/node_modules/linkedom/cjs/html/anchor-element.js:19:55)
at y.updateLinkDOM (file:///var/app/current/node_modules/@lexical/link/LexicalLink.prod.mjs:9:1231)
at y.createDOM (file:///var/app/current/node_modules/@lexical/link/LexicalLink.prod.mjs:9:1125)
at y.exportDOM (file:///var/app/current/node_modules/lexical/Lexical.prod.mjs:9:32114)
at y.exportDOM (file:///var/app/current/node_modules/lexical/Lexical.prod.mjs:9:88429)
at x (file:///var/app/current/node_modules/@lexical/html/LexicalHtml.prod.mjs:9:1403)
at x (file:///var/app/current/node_modules/@lexical/html/LexicalHtml.prod.mjs:9:1543)
at x (file:///var/app/current/node_modules/@lexical/html/LexicalHtml.prod.mjs:9:1543)
at g (file:///var/app/current/node_modules/@lexical/html/LexicalHtml.prod.mjs:9:1128)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions