From d5c22083486c519ce0b7f0cf6280f11b94bc27aa Mon Sep 17 00:00:00 2001 From: Nathan L Smith Date: Wed, 18 Sep 2024 16:32:24 -0500 Subject: [PATCH] Fix code scanning alert #419: Incomplete string escaping or encoding Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../metrics_explorer/components/helpers/create_tsvb_link.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts index ee64069cea737..c4ad0cdcf812c 100644 --- a/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts +++ b/x-pack/plugins/observability_solution/infra/public/pages/metrics/metrics_explorer/components/helpers/create_tsvb_link.ts @@ -114,7 +114,7 @@ export const createFilterFromOptions = ( filters.push(options.filterQuery); } if (options.groupBy) { - const id = series.id.replace('"', '\\"'); + const id = series.id.replace(/"/g, '\\"'); const groupByFilters = Array.isArray(options.groupBy) ? options.groupBy .map((field, index) => { @@ -125,7 +125,7 @@ export const createFilterFromOptions = ( if (!value) { return null; } - return `${field}: "${value.replace('"', '\\"')}"`; + return `${field}: "${value.replace(/"/g, '\\"')}"`; }) .join(' and ') : `${options.groupBy} : "${id}"`;