From 67e85389d139a190dc486a10c5e343dc663c9a81 Mon Sep 17 00:00:00 2001 From: Alex-D Date: Thu, 28 May 2020 22:06:59 +0200 Subject: [PATCH] docs(ui): add comments to add context on special characters escaping --- ui/src/helpers/formatConfigExtract.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/src/helpers/formatConfigExtract.ts b/ui/src/helpers/formatConfigExtract.ts index aa45c1c7..5ee57954 100644 --- a/ui/src/helpers/formatConfigExtract.ts +++ b/ui/src/helpers/formatConfigExtract.ts @@ -23,8 +23,10 @@ export default function formatConfigExtract(configError: ConfigError): string { try { JSON.parse(configExtract) } catch (err) { + // Escape special characters to display the config as text, not as HTML const sanitizedConfigExtract = configExtract .replace(/[\u00A0-\u9999<>&]/gim, (match) => { + // Replace with the HTML Entity of the character return `&#${match.charCodeAt(0)};` }) .replace(/\\\\/g, '\\')