Fix code scanning alert #419: Incomplete string escaping or encoding (#193365)

Fixes
[https://github.com/elastic/kibana/security/code-scanning/419](https://github.com/elastic/kibana/security/code-scanning/419)

_Suggested fixes powered by Copilot Autofix. Review carefully before
merging._

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
Nathan L Smith 2024-09-20 13:12:20 -05:00 committed by GitHub
parent 374351af56
commit 35edfd0edc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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}"`;