From 430bc1c25637ce932059758097c9570be4d17949 Mon Sep 17 00:00:00 2001
From: "google-labs-jules[bot]"
<161369871+google-labs-jules[bot]@users.noreply.github.com>
Date: Thu, 12 Mar 2026 00:31:09 +0000
Subject: [PATCH] =?UTF-8?q?=F0=9F=94=92=20Fix=20XSS=20in=20file=20list=20r?=
=?UTF-8?q?endering?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Improved escapeHtml to include quote escaping.
- Used escapeHtml for all filename and fileId interpolations in public/index.html.
- Refactored event handlers to use data- attributes and this.dataset for safe parameter passing.
- Used CSS.escape for safe attribute selection in querySelector.
- Added safety checks for DOM element existence.
- Fixed a duplicate saveComment function.
Co-authored-by: praxstack <73683289+praxstack@users.noreply.github.com>
---
public/index.html | 110 ++++++++++++++++++++++------------------------
1 file changed, 52 insertions(+), 58 deletions(-)
diff --git a/public/index.html b/public/index.html
index 44fbbc0..5c5ce88 100644
--- a/public/index.html
+++ b/public/index.html
@@ -978,55 +978,25 @@
💡 Quick Templates:
textarea.setSelectionRange(cursorPos + template.length, cursorPos + template.length);
}
- function saveComment() {
- const textarea = document.getElementById('commentTextarea');
- const comment = textarea.value.trim();
-
- if (comment) {
- fileComments[currentCommentFile] = comment;
-
- // Update comment button to show it has a comment
- const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
- if (commentBtn) {
- commentBtn.classList.add('has-comment');
- const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
- if (indicator) {
- indicator.style.display = 'inline';
- }
- }
-
- // Add comment display to the file
- showCommentInFile(currentCommentFile, currentCommentFileId, comment);
- } else {
- // Remove comment if empty
- delete fileComments[currentCommentFile];
- const commentBtn = document.querySelector(`[onclick*="'${currentCommentFile}'"]`);
- if (commentBtn) {
- commentBtn.classList.remove('has-comment');
- const indicator = document.getElementById(`comment-indicator-${currentCommentFileId}`);
- if (indicator) {
- indicator.style.display = 'none';
- }
- }
- removeCommentFromFile(currentCommentFileId);
- }
-
- closeCommentModal();
- }
function showCommentInFile(file, fileId, comment) {
// Remove existing comment display
removeCommentFromFile(fileId);
// Add comment display after file header
- const fileItem = document.getElementById(`diff-${fileId}`).parentElement;
+ const diffElem = document.getElementById(`diff-${fileId}`);
+ if (!diffElem) return;
+
+ const fileItem = diffElem.parentElement;
const commentDiv = document.createElement('div');
commentDiv.id = `comment-display-${fileId}`;
commentDiv.className = 'comment-display';
commentDiv.innerHTML = `💭 Your Comment:
${escapeHtml(comment)}`;
const fileHeader = fileItem.querySelector('.file-header');
- fileHeader.parentNode.insertBefore(commentDiv, fileHeader.nextSibling);
+ if (fileHeader) {
+ fileHeader.parentNode.insertBefore(commentDiv, fileHeader.nextSibling);
+ }
}
function removeCommentFromFile(fileId) {
@@ -1207,20 +1177,24 @@ No Staged Changes
const fileDiv = document.createElement('div');
fileDiv.className = 'file-item';
fileDiv.innerHTML = `
-