From b8aa31433b5d23e7fa4b5c8be3864d941ebace54 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 10 Oct 2022 08:49:00 -0400 Subject: [PATCH] Loki: Escape label-values in context queries (#56614) (#56639) (cherry picked from commit 62674604b454f77bf7276bd2aba6319e08f838e0) Co-authored-by: Sven Grossmann --- public/app/plugins/datasource/loki/datasource.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts index 5c3163277d2..484889c6ef6 100644 --- a/public/app/plugins/datasource/loki/datasource.ts +++ b/public/app/plugins/datasource/loki/datasource.ts @@ -49,7 +49,7 @@ import LanguageProvider from './LanguageProvider'; import { LiveStreams, LokiLiveTarget } from './LiveStreams'; import { transformBackendResult } from './backendResultTransformer'; import { LokiAnnotationsQueryEditor } from './components/AnnotationsQueryEditor'; -import { escapeLabelValueInSelector, isRegexSelector } from './languageUtils'; +import { escapeLabelValueInExactSelector, escapeLabelValueInSelector, isRegexSelector } from './languageUtils'; import { labelNamesRegex, labelValuesRegex } from './migrations/variableQueryMigrations'; import { addLabelFormatToQuery, @@ -577,7 +577,7 @@ export class LokiDatasource .map((label: string) => { if (labels.includes(label)) { // escape backslashes in label as users can't escape them by themselves - return `${label}="${row.labels[label].replace(/\\/g, '\\\\')}"`; + return `${label}="${escapeLabelValueInExactSelector(row.labels[label])}"`; } return ''; })