Skip to content
Merged
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
11 changes: 10 additions & 1 deletion Frontend/src/components/shared/TicketChat.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import React, { useState, useRef, useEffect, useCallback } from 'react';

// Basic XSS sanitization: removes script tags and inline event handlers
const sanitizeMessage = (text) => {
if (!text) return text;
return text
.replace(/<script.*?>.*?<\/script>/gi, '')
.replace(/ on\w+="[^"]*"/g, '')
.replace(/ on\w+='[^']*'/g, '');
};
import { Send, User, ShieldCheck, Bot, MessageSquare, Circle, Loader2 } from 'lucide-react';
import { supabase } from "../../lib/supabaseClient";
import useAuthStore from "../../store/authStore";
Expand Down Expand Up @@ -177,7 +186,7 @@ const TicketChat = ({ ticketId, currentUserRole = 'user' }) => {
sender_id: user.id,
sender_name: profile?.full_name || user.email,
sender_role: profile?.role || 'user',
message: content,
message: sanitizeMessage(content),
is_internal: currentIsInternal,
created_at: new Date().toISOString()
};
Expand Down