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 {