expand sub tasks

This commit is contained in:
chamiakJ
2025-07-03 01:31:05 +05:30
parent 3bef18901a
commit ecd4d29a38
435 changed files with 13150 additions and 11087 deletions

View File

@@ -2,34 +2,34 @@ import DOMPurify from 'dompurify';
/**
* Sanitizes user input to prevent XSS attacks
*
*
* @param input - The user input string to sanitize
* @param options - Optional configuration for DOMPurify
* @returns Sanitized string
*/
export const sanitizeInput = (input: string, options?: DOMPurify.Config): string => {
if (!input) return '';
// Default options for plain text inputs (strip all HTML)
const defaultOptions: DOMPurify.Config = {
ALLOWED_TAGS: [],
ALLOWED_ATTR: [],
};
return DOMPurify.sanitize(input, options || defaultOptions);
};
/**
* Sanitizes a string for use in HTML contexts (allows some basic tags)
*
*
* @param input - The input containing HTML to sanitize
* @returns Sanitized HTML string
*/
export const sanitizeHtml = (input: string): string => {
if (!input) return '';
return DOMPurify.sanitize(input, {
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'a', 'p', 'br', 'span'],
ALLOWED_ATTR: ['href', 'target', 'rel', 'class'],
});
};
};