Fix CSP violation by using event delegation for reply form buttons

This commit is contained in:
2026-01-30 23:51:29 -05:00
parent 6dff92db45
commit 651c8115f6

View File

@@ -1252,6 +1252,12 @@ document.addEventListener('DOMContentLoaded', function() {
case 'reply-comment':
showReplyForm(parseInt(target.dataset.commentId), target.dataset.user);
break;
case 'close-reply':
closeReplyForm();
break;
case 'submit-reply':
submitReply(parseInt(target.dataset.parentId));
break;
case 'edit-comment':
editComment(parseInt(target.dataset.commentId));
break;
@@ -1471,7 +1477,7 @@ function showReplyForm(commentId, userName) {
<div class="reply-form-container" data-parent-id="${commentId}">
<div class="reply-header">
<span>Replying to <span class="replying-to">@${userName}</span></span>
<button type="button" class="close-reply-btn" onclick="closeReplyForm()">Cancel</button>
<button type="button" class="close-reply-btn" data-action="close-reply">Cancel</button>
</div>
<textarea id="replyText" placeholder="Write your reply..."></textarea>
<div class="reply-actions">
@@ -1480,7 +1486,7 @@ function showReplyForm(commentId, userName) {
<span>Markdown</span>
</label>
<div class="reply-buttons">
<button type="button" class="btn btn-small" onclick="submitReply(${commentId})">Reply</button>
<button type="button" class="btn btn-small" data-action="submit-reply" data-parent-id="${commentId}">Reply</button>
</div>
</div>
</div>