import sanitizeHtml from 'sanitize-html';
// Server-side input sanitization to prevent CSS injection and XSS attacks
export function sanitizeInput(input) {
if (typeof input !== 'string') {
return input;
}
// Remove any HTML tags and dangerous content
// DOMPurify needs a browser window. On Node its default export is a
// factory without .sanitize(), which aborted JSON exports on the first
// HTML-bearing card. Parse on the server without a DOM or network access.
const sanitized = sanitizeHtml(input, {
allowedTags: [],
allowedAttributes: {},
});
// Additional check for CSS injection patterns
const cssInjectionPatterns = [
/