Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions orbit-app/src/components/CommentsSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
Expand Down