Skip to content

Commit

Permalink
[8.x] [ESQL] String escaping fix (#196643) (#196676)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ESQL] String escaping fix
(#196643)](#196643)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Elena
Shostak","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-17T11:37:05Z","message":"[ESQL]
String escaping fix (#196643)\n\n## Summary\r\n\r\nTo PR fix the problem
with string escaping, we need to ensure that\r\nbackslashes are properly
escaped in addition to double quotes.\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"9ddf0e11ef0e004ccf9002061e9191c7739d9eb6","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:ESQL"],"title":"[ESQL]
String escaping
fix","number":196643,"url":"https://github.com/elastic/kibana/pull/196643","mergeCommit":{"message":"[ESQL]
String escaping fix (#196643)\n\n## Summary\r\n\r\nTo PR fix the problem
with string escaping, we need to ensure that\r\nbackslashes are properly
escaped in addition to double quotes.\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"9ddf0e11ef0e004ccf9002061e9191c7739d9eb6"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196643","number":196643,"mergeCommit":{"message":"[ESQL]
String escaping fix (#196643)\n\n## Summary\r\n\r\nTo PR fix the problem
with string escaping, we need to ensure that\r\nbackslashes are properly
escaped in addition to double quotes.\r\n\r\nCo-authored-by: Copilot
Autofix powered by AI
<62310815+github-advanced-security[bot]@users.noreply.github.com>","sha":"9ddf0e11ef0e004ccf9002061e9191c7739d9eb6"}}]}]
BACKPORT-->

Co-authored-by: Elena Shostak <[email protected]>
  • Loading branch information
kibanamachine and elena-shostak authored Oct 17, 2024
1 parent 4849b41 commit e1e7198
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 e1e7198

Please sign in to comment.