add html decoding to pronoun sanitation

This commit is contained in:
ItsVipra 2023-07-19 11:55:18 +02:00
parent 42b954f209
commit bd14d190a2
No known key found for this signature in database

View file

@ -1,4 +1,5 @@
import sanitizeHtml from "sanitize-html"; 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 fieldMatchers = [/\bpro.*nouns?\b/i, /\bpronomen\b/i, /(i )?go(es)? by/i];
const knownPronounUrls = [ const knownPronounUrls = [
@ -179,9 +180,12 @@ function sanitizePronouns(str) {
// Remove trailing characters that are used as separators. // Remove trailing characters that are used as separators.
str = str.replace(/[-| :/]+$/, ""); str = str.replace(/[-| :/]+$/, "");
// Finally, remove leading and trailing whitespace. // Remove leading and trailing whitespace.
str = str.trim(); 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. // If the result is empty, return null, otherwise the empty string.
return str === "" ? null : str; return str === "" ? null : str;
} }