From b1125c0ba323af5f3335338ceed4801455ebab2a Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Thu, 3 Mar 2022 16:50:09 +0000 Subject: [PATCH] TextPanel: Sanitize after markdown has been rendered to html (#46166) * Sanitize after markdown has been rendered to html * Update e2e test --- e2e/dashboards-suite/dashboard-templating.spec.ts | 2 +- public/app/plugins/panel/text/TextPanel.tsx | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/e2e/dashboards-suite/dashboard-templating.spec.ts b/e2e/dashboards-suite/dashboard-templating.spec.ts index a7c4db01033..4a6187e4be1 100644 --- a/e2e/dashboards-suite/dashboard-templating.spec.ts +++ b/e2e/dashboards-suite/dashboard-templating.spec.ts @@ -27,7 +27,7 @@ e2e.scenario({ `Server:pipe = A'A"A|BB\\B|CCC`, `Server:distributed = A'A"A,Server=BB\\B,Server=CCC`, `Server:csv = A'A"A,BB\\B,CCC`, - `Server:html = A'A"A, BB\\B, CCC`, + `Server:html = A'A"A, BB\\B, CCC`, `Server:json = ["A'A\\"A","BB\\\\B","CCC"]`, `Server:percentencode = %7BA%27A%22A%2CBB%5CB%2CCCC%7D`, `Server:singlequote = 'A\\'A"A','BB\\B','CCC'`, diff --git a/public/app/plugins/panel/text/TextPanel.tsx b/public/app/plugins/panel/text/TextPanel.tsx index f0251f9d658..b9e918ce259 100644 --- a/public/app/plugins/panel/text/TextPanel.tsx +++ b/public/app/plugins/panel/text/TextPanel.tsx @@ -44,9 +44,11 @@ export class TextPanel extends PureComponent { prepareMarkdown(content: string): string { // Sanitize is disabled here as we handle that after variable interpolation - return renderTextPanelMarkdown(this.interpolateAndSanitizeString(content), { - noSanitize: config.disableSanitizeHtml, - }); + return this.interpolateAndSanitizeString( + renderTextPanelMarkdown(content, { + noSanitize: config.disableSanitizeHtml, + }) + ); } interpolateAndSanitizeString(content: string): string {