Skip to content

Commit

Permalink
[ESQL] String escaping fix (#196643)
Browse files Browse the repository at this point in the history
## Summary

To PR fix the problem with string escaping, we need to ensure that
backslashes are properly escaped in addition to double quotes.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent dc3dda7 commit 9ddf0e1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/kbn-esql-utils/src/utils/append_to_query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export function appendWhereClauseToESQLQuery(
default:
operator = '==';
}
let filterValue = typeof value === 'string' ? `"${value.replace(/\"/g, '\\"')}"` : value;
let filterValue =
typeof value === 'string' ? `"${value.replace(/\\/g, '\\\\').replace(/\"/g, '\\"')}"` : value;
// Adding the backticks here are they are needed for special char fields
let fieldName = `\`${field}\``;

Expand Down

0 comments on commit 9ddf0e1

Please sign in to comment.