fix: CodeQL double escape warning

This commit is contained in:
saurabhg772244
2025-02-18 15:42:25 +05:30
parent 62edea6b33
commit 1182aaaf4d

View File

@@ -372,8 +372,8 @@ export const addLinks = function (actorId: string, text: { text: string }) {
// JSON.parse the text
try {
let sanitizedText = sanitizeText(text.text, getConfig());
sanitizedText = sanitizedText.replace(/&/g, '&');
sanitizedText = sanitizedText.replace(/=/g, '=');
sanitizedText = sanitizedText.replace(/&/g, '&');
const links = JSON.parse(sanitizedText);
// add the deserialized text to the actor's links field.
insertLinks(actor, links);
@@ -389,8 +389,8 @@ export const addALink = function (actorId: string, text: { text: string }) {
const links: Record<string, string> = {};
let sanitizedText = sanitizeText(text.text, getConfig());
const sep = sanitizedText.indexOf('@');
sanitizedText = sanitizedText.replace(/&amp;/g, '&');
sanitizedText = sanitizedText.replace(/&equals;/g, '=');
sanitizedText = sanitizedText.replace(/&amp;/g, '&');
const label = sanitizedText.slice(0, sep - 1).trim();
const link = sanitizedText.slice(sep + 1).trim();