Skip to content

Commit

Permalink
[7.17] [Console] Fix double escaping issue from code scan (#194938) (#…
Browse files Browse the repository at this point in the history
…195163)

# Backport

This will backport the following commits from `main` to `7.17`:
- [[Console] Fix double escaping issue from code scan
(#194938)](#194938)

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

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

<!--BACKPORT [{"author":{"name":"Ignacio
Rivas","email":"rivasign@gmail.com"},"sourceCommit":{"committedDate":"2024-10-05T05:52:18Z","message":"[Console]
Fix double escaping issue from code scan
(#194938)","sha":"c51f8506aad1e0707591549faaf81ad9af8b42e3","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Console","Team:Kibana
Management","release_note:skip","v9.0.0","backport:all-open"],"title":"[Console]
Fix double escaping issue from code
scan","number":194938,"url":"https://github.com/elastic/kibana/pull/194938","mergeCommit":{"message":"[Console]
Fix double escaping issue from code scan
(#194938)","sha":"c51f8506aad1e0707591549faaf81ad9af8b42e3"}},"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/194938","number":194938,"mergeCommit":{"message":"[Console]
Fix double escaping issue from code scan
(#194938)","sha":"c51f8506aad1e0707591549faaf81ad9af8b42e3"}}]}]
BACKPORT-->

Co-authored-by: Ignacio Rivas <rivasign@gmail.com>
  • Loading branch information
kibanamachine and sabarasaba authored Oct 5, 2024
1 parent ee2e834 commit 2802b12
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/plugins/console/public/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ export function extractWarningMessages(warnings: string) {
});
}

// To avoid double unescaping, the best approach is to process the backslash escape sequence last.
// This ensures that any escaped characters are correctly handled first, preventing premature
// interpretation of the backslash itself as part of another escape sequence.
export function unescape(s: string) {
return s.replace(/\\\\/g, '\\').replace(/\\"/g, '"');
return s.replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}

export function splitOnUnquotedCommaSpace(s: string) {
Expand Down

0 comments on commit 2802b12

Please sign in to comment.