From 2d0a1a07064f66d3757445ae4f88612c6d856eb8 Mon Sep 17 00:00:00 2001 From: Sameer <142401625+sameer6pre@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:55:47 +0530 Subject: [PATCH] Update orbit-app/src/components/CommentsSection.jsx in branch Precogs-fix-wh6etdsi --- orbit-app/src/components/CommentsSection.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/orbit-app/src/components/CommentsSection.jsx b/orbit-app/src/components/CommentsSection.jsx index 6fe0c21..e98330e 100644 --- a/orbit-app/src/components/CommentsSection.jsx +++ b/orbit-app/src/components/CommentsSection.jsx @@ -17,18 +17,24 @@ function CommentsSection() { }); }, []); - const handleSubmit = (e) => { +(e) => { e.preventDefault(); - axios.post(`${BASE_URL}/comments`, { comment }) + const sanitizedComment = sanitizeInput(comment); // FIX: Sanitize the input before sending it to the server + axios.post(`${BASE_URL}/comments`, { comment: sanitizedComment }) .then(response => { alert('Comment added!'); - setCommentsList([...commentsList, { comment }]); + setCommentsList([...commentsList, { comment: sanitizedComment }]); setComment(''); }) .catch(error => { console.error('Error posting comment:', error); }); - }; + } + +function sanitizeInput(input) { + // Implement a proper sanitization function here + return input.replace(/<[^>]*>?/gm, ''); // Example: Remove HTML tags +} return (