batches: Handle unbalanced quote
Created by: Piszmog
Closes #40415 (closed).
A search query that contains a colon (:
) and unbalanced quotes ("foo
) causes an edge case where the string does not get escaped properly.
Take the example search query - "license": "Apache-2.0
.
When determining whether to escape this string, when the value is tested to be loaded with double quotes (after failing the test load with no quotes) . This causes the YAML to be loaded/parsed successfully (it makes the YAML parser think there are 2 separate mappings instead of 1).
The logic,
-
name: context:global "license": "Apache-2.0 patternType:standard
fails to be parsed. - Try to parse
name: "context:global "license": "Apache-2.0 patternType:standard"
- The new YAML is parsed successfully with 2 mappings
name: "context:global "
license": ""Apache-2.0 patternType:standard"
- The logic decides there is no need to escape any quotes since everything is parsed correctly.
I updated the code to check if there are more than one mappings. I assume that since we are trying to escape a string that there should only ever be a single mapping.
Test plan
Added new Jest Unit Tests and did functional testing.
App preview:
Check out the client app preview documentation to learn more.