From 275e70b42dd42327cf437c3b98c8124363ee44ae Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Fri, 13 Nov 2026 14:21:48 +0100 Subject: [PATCH] fix(admin): encode parentheses in markdown mail image URLs Co-authored-by: Cursor --- admin/src/components/mail/insertImage.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/admin/src/components/mail/insertImage.ts b/admin/src/components/mail/insertImage.ts index 1eb7ee1d..670405e0 100644 --- a/admin/src/components/mail/insertImage.ts +++ b/admin/src/components/mail/insertImage.ts @@ -8,7 +8,8 @@ function escapeMarkdownAlt(alt: string): string { /** Percent-encode spaces and parentheses in Markdown URLs (research Pitfall 4). */ function encodeMarkdownUrl(url: string): string { - return url.replace(/[ ()]/g, (ch) => encodeURIComponent(ch)) + // encodeURIComponent leaves () alone; Markdown link destinations need them escaped. + return url.replace(/[ ()]/g, (ch) => (ch === ' ' ? '%20' : ch === '(' ? '%28' : '%29')) } function escapeHtmlAttr(value: string): string {