From 7245dc57f437a9216aeb69825d0af0563bbd9ddf Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 15 Oct 2024 20:34:51 +1100 Subject: [PATCH] [8.x] [Lens] escape backslash characters in the formula input (#196171) (#196237) # Backport This will backport the following commits from `main` to `8.x`: - [[Lens] escape backslash characters in the formula input (#196171)](https://github.com/elastic/kibana/pull/196171) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Marta Bondyra <4283304+mbondyra@users.noreply.github.com> --- .../form_based/operations/definitions/formula/generate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts index a2f94fb437062..b13c3ff261207 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/operations/definitions/formula/generate.ts @@ -79,7 +79,7 @@ export function generateFormula( } previousFormula += (previousColumn.filter.language === 'kuery' ? 'kql=' : 'lucene=') + - `'${previousColumn.filter.query.replace(/'/g, `\\'`)}'`; // replace all + `'${previousColumn.filter.query.replace(/\\/g, '\\\\').replace(/'/g, `\\'`)}'`; // replace all } if (previousColumn.timeShift) { if (