From 7802ce9421cdcbca3807c86d901b6b287a47cf1f Mon Sep 17 00:00:00 2001 From: "vitalii.semianchuk" Date: Wed, 15 Jul 2026 20:21:27 +0100 Subject: [PATCH] Fix duplicate regex capture group in HTML link attribute parser The HTML_LINK_ATTR_RE regex in asset-references.ts had an unreachable third capture group that was identical to the first (both matching ASCII double-quoted attribute values). The regex engine always matches group 1 first, making group 3 dead code. Replace the duplicate with a curly/smart quote alternative (\u201c...\u201d) so pasted HTML with typographic quotes is handled correctly. --- packages/server/src/asset-references.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/asset-references.ts b/packages/server/src/asset-references.ts index 1fd70605c..837cfd52b 100644 --- a/packages/server/src/asset-references.ts +++ b/packages/server/src/asset-references.ts @@ -24,7 +24,7 @@ const MARKDOWN_LINK_OR_IMAGE_RE = /!?\[[^\]\n]*(?:\][^[\]\n]*)?\]\((?:<([^>\n]+)>|([^)\s]+))(?:\s+['"][^'"]*['"])?\)/g; const WIKI_LINK_OR_EMBED_RE = /!?\[\[([^[\]|#]+?)(?:#[^\]|]+?)?(?:\|[^\]]+?)?\]\]/g; const HTML_LINK_ATTR_RE = - /<[\w:-]+\b[^>]*?\s+(?:href|src)\s*=\s*(?:"([^"\n]*)"|'([^'\n]*)'|“([^”\n]*)”|([^\s"'=<>`]+))/gi; + /<[\w:-]+\b[^>]*?\s+(?:href|src)\s*=\s*(?:”([^”\n]*)”|'([^'\n]*)'|\u201c([^\u201d\n]*)\u201d|([^\s”'=<>`]+))/gi; export function isRemoteOrOpaqueHref(href: string): boolean { return (