/** * Sanitization utilities for preventing XSS, SQL injection, and path traversal attacks. */ /** * Escape HTML to prevent XSS attacks * Replaces HTML special characters with their entity equivalents * * @param str - The string to escape * @returns The escaped HTML string * * @example * ```typescript * escapeHtml(''); * // Returns: '<script>alert("XSS")</script>' * ``` */ export declare function escapeHtml(str: string): string; /** * Remove potentially dangerous SQL characters * Note: This is NOT a replacement for parameterized queries! * Always use parameterized queries/prepared statements for database operations. * * @param str - The string to sanitize * @returns The sanitized string with dangerous SQL characters removed * * @example * ```typescript * sanitizeSql("admin'; DROP TABLE users--"); * // Returns: "admin DROP TABLE users--" * ``` */ export declare function sanitizeSql(str: string): string; /** * Sanitize filename to prevent path traversal attacks * Removes path separators and special characters, limits length * * @param filename - The filename to sanitize * @returns A safe filename * * @example * ```typescript * sanitizeFilename('../../etc/passwd'); * // Returns: '.._.._etc_passwd' * * sanitizeFilename('my file<>:"/\\|?*.txt'); * // Returns: 'my_file_.txt' * ``` */ export declare function sanitizeFilename(filename: string): string; /** * Strip all HTML tags from a string * Removes all content between < and > characters * * @param str - The string to strip * @returns The string with all HTML tags removed * * @example * ```typescript * stripHtml('

Hello World!

'); * // Returns: 'Hello World!' * ``` */ export declare function stripHtml(str: string): string; /** * Sanitize URL to prevent javascript: and data: URI attacks * Only allows http, https, and relative URLs * * @param url - The URL to sanitize * @returns The sanitized URL or '#' if invalid * * @example * ```typescript * sanitizeUrl('javascript:alert("XSS")'); * // Returns: '#' * * sanitizeUrl('https://example.com'); * // Returns: 'https://example.com' * ``` */ export declare function sanitizeUrl(url: string): string; //# sourceMappingURL=sanitize.d.ts.map