From 9711d60c2c3cb93b1674b2d6cb1d282d81a1ec4c Mon Sep 17 00:00:00 2001 From: Oliver Laxenta Date: Fri, 26 Jun 2026 23:12:04 +0530 Subject: [PATCH] Potential fix for code scanning alert no. 5: DOM text reinterpreted as HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- src/app/components/FeedbackCards.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app/components/FeedbackCards.tsx b/src/app/components/FeedbackCards.tsx index a3e8106..9fe075f 100644 --- a/src/app/components/FeedbackCards.tsx +++ b/src/app/components/FeedbackCards.tsx @@ -258,6 +258,13 @@ function ReplySection({ threadId, initialReplies, isAdmin }: { threadId: string, setPreviews(prev => prev.filter((_, i) => i !== idx)); }; + const getSafeImagePreviewSrc = (src: string): string => { + if (typeof src !== 'string') return ''; + if (src.startsWith('blob:')) return src; + if (/^data:image\/[a-zA-Z0-9.+-]+;base64,[a-zA-Z0-9+/=\s]+$/.test(src)) return src; + return ''; + }; + const handleReply = async () => { if ((!replyText.trim() && images.length === 0) || isSubmitting) return; setIsSubmitting(true); @@ -387,7 +394,7 @@ function ReplySection({ threadId, initialReplies, isAdmin }: { threadId: string, {previews.map((src, i) => (
{/* CodeQL fix: sanitize image src */} - +