From bd14d190a2f757899eb795f618da186750af98a3 Mon Sep 17 00:00:00 2001 From: ItsVipra Date: Wed, 19 Jul 2023 11:55:18 +0200 Subject: [PATCH] add html decoding to pronoun sanitation --- src/libs/pronouns.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libs/pronouns.js b/src/libs/pronouns.js index aacc82e..0f0a708 100644 --- a/src/libs/pronouns.js +++ b/src/libs/pronouns.js @@ -1,4 +1,5 @@ import sanitizeHtml from "sanitize-html"; +import { htmlDecode } from "./domhelpers.js"; const fieldMatchers = [/\bpro.*nouns?\b/i, /\bpronomen\b/i, /(i )?go(es)? by/i]; const knownPronounUrls = [ @@ -179,9 +180,12 @@ function sanitizePronouns(str) { // Remove trailing characters that are used as separators. str = str.replace(/[-| :/]+$/, ""); - // Finally, remove leading and trailing whitespace. + // Remove leading and trailing whitespace. str = str.trim(); + //Finally, turn escaped characters (e.g. &,>) back into their original form + str = htmlDecode(str); + // If the result is empty, return null, otherwise the empty string. return str === "" ? null : str; }