From ebae55f158a770abba96c094f171612a6ae2dd1c Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sun, 11 Oct 2026 15:32:33 -0700 Subject: [PATCH] Sonar --- src-ui/src/app/pipes/markdown.pipe.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src-ui/src/app/pipes/markdown.pipe.ts b/src-ui/src/app/pipes/markdown.pipe.ts index 492cce77b..1b6c39274 100644 --- a/src-ui/src/app/pipes/markdown.pipe.ts +++ b/src-ui/src/app/pipes/markdown.pipe.ts @@ -1,21 +1,21 @@ import { Pipe, PipeTransform } from '@angular/core' import { Marked, Renderer, Tokens } from 'marked' -const ALLOWED_LINK_PROTOCOLS = ['http:', 'https:', 'mailto:'] +const ALLOWED_LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:']) function escapeHtml(text: string): string { return text - .replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, ''') + .replaceAll('&', '&') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('"', '"') + .replaceAll("'", ''') } function safeHref(href: string): string | null { try { const url = new URL(href) - return ALLOWED_LINK_PROTOCOLS.includes(url.protocol) ? url.href : null + return ALLOWED_LINK_PROTOCOLS.has(url.protocol) ? url.href : null } catch { return null }