File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
src/legacy/core_plugins/console/public/quarantined Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,20 @@ utils.expandLiteralStrings = function(data) {
8888 // Expand to triple quotes if there are _any_ slashes
8989 if ( string . match ( / \\ ./ ) ) {
9090 const firstDoubleQuoteIdx = string . indexOf ( '"' ) ;
91+ const lastDoubleQuoteIdx = string . lastIndexOf ( '"' ) ;
92+
93+ // Handle a special case where we may have a value like "\"test\"". We don't
94+ // want to expand this to """"test"""" - so we terminate before processing the string
95+ // further if we detect this either at the start or end of the double quote section.
96+
97+ if ( string [ firstDoubleQuoteIdx + 1 ] === '\\' && string [ firstDoubleQuoteIdx + 2 ] === '"' ) {
98+ return string ;
99+ }
100+
101+ if ( string [ lastDoubleQuoteIdx - 1 ] === '"' && string [ lastDoubleQuoteIdx - 2 ] === '\\' ) {
102+ return string ;
103+ }
104+
91105 const colonAndAnySpacing = string . slice ( 0 , firstDoubleQuoteIdx ) ;
92106 const rawStringifiedValue = string . slice ( firstDoubleQuoteIdx , string . length ) ;
93107 const jsonValue = JSON . parse ( rawStringifiedValue )
Original file line number Diff line number Diff line change @@ -40,3 +40,33 @@ Correctly parse with JSON embedded inside values
4040 "content\\\\": """ { "json": "inside\\" ok! 1
4141 " } """
4242}
43+ ==========
44+ Single quotes escaped special case, start and end
45+ -------------------------------------
46+ {
47+ "query": "\"test\""
48+ }
49+ -------------------------------------
50+ {
51+ "query": "\"test\""
52+ }
53+ ==========
54+ Single quotes escaped special case, start
55+ -------------------------------------
56+ {
57+ "query": "\"test"
58+ }
59+ -------------------------------------
60+ {
61+ "query": "\"test"
62+ }
63+ ==========
64+ Single quotes escaped special case, end
65+ -------------------------------------
66+ {
67+ "query": "test\""
68+ }
69+ -------------------------------------
70+ {
71+ "query": "test\""
72+ }
You can’t perform that action at this time.
0 commit comments