fix(editor): Prevent clipboard XSS injection (#10805)

This commit is contained in:
Raúl Gómez Morales
2024-09-16 08:36:40 +02:00
committed by GitHub
parent cef64329a9
commit db846d3235
4 changed files with 48 additions and 12 deletions

View File

@@ -37,6 +37,17 @@ export function sanitizeHtml(dirtyHtml: string) {
return sanitizedHtml;
}
/**
* Checks if the input is a string and sanitizes it by removing or escaping harmful characters,
* returning the original input if it's not a string.
*/
export const sanitizeIfString = <T>(message: T): string | T => {
if (typeof message === 'string') {
return sanitizeHtml(message);
}
return message;
};
export function setPageTitle(title: string) {
window.document.title = title;
}