- Add shared escapeHtml utility function - Apply text sanitization to title/description in content.ts - Refactor linkedin.ts to use shared utility
11 lines
320 B
TypeScript
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;
|
|
}
|