diff --git a/src/core/operations/ParseAITokens.mjs b/src/core/operations/ParseAITokens.mjs index b56d85d8..06d4c5f6 100644 --- a/src/core/operations/ParseAITokens.mjs +++ b/src/core/operations/ParseAITokens.mjs @@ -95,7 +95,8 @@ class ParseAITokens extends Operation { const tokenHtml = tokens.map((t, i) => { const tok = - t.replaceAll(" ", "\u00A0") + t.replace(/[\u00A0-\u9999<>&]/g, i => "&#"+i.charCodeAt(0)+";") + .replaceAll(" ", "\u00A0") .replaceAll("\n", ""); const css = [ @@ -127,21 +128,29 @@ class ParseAITokens extends Operation { }; /** - * Replace all space not starting within the HTML tag. - * @param {string} htmlString - * @returns {string} + * Replace spaces outside HTML tags and sanitize