mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-11 13:56:16 +00:00
fix: eslint error
This commit is contained in:
@@ -6,6 +6,21 @@ function removeZalgoText(text: string): string {
|
||||
return text.replace(zalgoRegex, "");
|
||||
}
|
||||
|
||||
function decodeHtmlEntities(text: string): string {
|
||||
const entityMap: { [key: string]: string } = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'",
|
||||
' ': ' ',
|
||||
};
|
||||
|
||||
return text.replace(/&[#\w]+;/g, (entity) => {
|
||||
return entityMap[entity] || entity;
|
||||
});
|
||||
}
|
||||
|
||||
export function sanitizeHtml(html: string): string {
|
||||
if (!html || typeof html !== "string") {
|
||||
return "";
|
||||
@@ -13,9 +28,7 @@ export function sanitizeHtml(html: string): string {
|
||||
|
||||
let cleanText = html.replace(/<[^>]*>/g, "");
|
||||
|
||||
const tempDiv = document.createElement("div");
|
||||
tempDiv.innerHTML = cleanText;
|
||||
cleanText = tempDiv.textContent || tempDiv.innerText || "";
|
||||
cleanText = decodeHtmlEntities(cleanText);
|
||||
|
||||
cleanText = removeZalgoText(cleanText);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user