Files
cal.diy/companion/extension/lib/utils.ts
T
Pedro Castro 5dfa1dfd74 fix: sanitize event type text in Gmail dropdown (#27533)
- Add shared escapeHtml utility function
 - Apply text sanitization to title/description in content.ts
 - Refactor linkedin.ts to use shared utility
2026-02-04 02:10:04 +05:30

11 lines
320 B
TypeScript

/**
* Escapes HTML special characters to prevent XSS attacks.
* Uses the browser's built-in text encoding via textContent.
*/
export function escapeHtml(text: string): string {
if (typeof text !== "string") return "";
const div = document.createElement("div");
div.textContent = text;
return div.innerHTML;
}