From 9bf0f48ba1adcd5d891de8bd61f2d436fbeacbd8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:33:11 +0000 Subject: [PATCH 1/6] Initial plan From 8f5a10e50ffb286b43dd4a8b4e16fe2837ee4e05 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:38:34 +0000 Subject: [PATCH 2/6] Preserve alt attribute when rewriting comment images Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --- src/github/prComment.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index d2ccba181e..3f8435b064 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -215,7 +215,8 @@ export class TemporaryComment extends CommentBase { } const SUGGESTION_EXPRESSION = /```suggestion(\u0020*(\r\n|\n))((?[\s\S]*?)(\r\n|\n))?```/; -const IMG_EXPRESSION = /.+?)['"].*?>/g; +const IMG_EXPRESSION = /.+?)['"].*?>/g; +const IMG_ALT_EXPRESSION = /alt=['"](?.*?)['"]/; const UUID_EXPRESSION = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}/; export const COMMIT_SHA_EXPRESSION = /(? { - return `![image](${src})`; + return body.replace(IMG_EXPRESSION, (substring, _1, _2, _3, { src }) => { + const altMatch = substring.match(IMG_ALT_EXPRESSION); + const alt = altMatch?.groups?.alt || 'image'; + return `![${alt}](${src})`; }); } From 2db0b63c56ce6cb4ef8fd8f02b3ffcd6dfa47b2f Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Wed, 3 Jun 2026 15:30:38 +0200 Subject: [PATCH 3/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/github/prComment.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 3f8435b064..e9830d1d9a 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -215,8 +215,8 @@ export class TemporaryComment extends CommentBase { } const SUGGESTION_EXPRESSION = /```suggestion(\u0020*(\r\n|\n))((?[\s\S]*?)(\r\n|\n))?```/; -const IMG_EXPRESSION = /.+?)['"].*?>/g; -const IMG_ALT_EXPRESSION = /alt=['"](?.*?)['"]/; +const IMG_EXPRESSION = /]*?\ssrc\s*=\s*['"](?[^'"]+?)['"][^>]*?>/gi; +const IMG_ALT_EXPRESSION = /\salt\s*=\s*['"](?[^'"]*)['"]/i; const UUID_EXPRESSION = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}/; export const COMMIT_SHA_EXPRESSION = /(? Date: Wed, 3 Jun 2026 15:30:57 +0200 Subject: [PATCH 4/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/github/prComment.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index e9830d1d9a..86ce4be060 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -355,8 +355,9 @@ export class GHPRComment extends CommentBase { private replaceImg(body: string) { return body.replace(IMG_EXPRESSION, (substring, _1, _2, _3, { src }) => { const altMatch = substring.match(IMG_ALT_EXPRESSION); - const alt = altMatch?.groups?.alt || 'image'; - return `![${alt}](${src})`; + const alt = (altMatch?.groups?.alt ?? '').replace(/[\r\n]+/g, ' ').trim(); + const safeAlt = alt.replace(/\\/g, '\\\\').replace(/\]/g, '\\]'); + return `![${safeAlt || 'image'}](${src})`; }); } From b5fb036e6195e2ee92f849f3cab046ec36fec095 Mon Sep 17 00:00:00 2001 From: Alex Ross <38270282+alexr00@users.noreply.github.com> Date: Wed, 3 Jun 2026 15:40:28 +0200 Subject: [PATCH 5/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/github/prComment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 86ce4be060..5ebb50d5cf 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -216,7 +216,7 @@ export class TemporaryComment extends CommentBase { const SUGGESTION_EXPRESSION = /```suggestion(\u0020*(\r\n|\n))((?[\s\S]*?)(\r\n|\n))?```/; const IMG_EXPRESSION = /]*?\ssrc\s*=\s*['"](?[^'"]+?)['"][^>]*?>/gi; -const IMG_ALT_EXPRESSION = /\salt\s*=\s*['"](?[^'"]*)['"]/i; +const IMG_ALT_EXPRESSION = /\salt\s*=\s*(['"])(?[\s\S]*?)\1/i; const UUID_EXPRESSION = /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}/; export const COMMIT_SHA_EXPRESSION = /(? Date: Wed, 3 Jun 2026 15:40:44 +0200 Subject: [PATCH 6/6] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/github/prComment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/github/prComment.ts b/src/github/prComment.ts index 5ebb50d5cf..eec7df13a0 100644 --- a/src/github/prComment.ts +++ b/src/github/prComment.ts @@ -356,7 +356,7 @@ export class GHPRComment extends CommentBase { return body.replace(IMG_EXPRESSION, (substring, _1, _2, _3, { src }) => { const altMatch = substring.match(IMG_ALT_EXPRESSION); const alt = (altMatch?.groups?.alt ?? '').replace(/[\r\n]+/g, ' ').trim(); - const safeAlt = alt.replace(/\\/g, '\\\\').replace(/\]/g, '\\]'); + const safeAlt = alt.replace(/([\\\[\]`])/g, '\\$1'); return `![${safeAlt || 'image'}](${src})`; }); }