Skip to content

batches: Handle unbalanced quote

Warren Gifford requested to merge rc/search-batch-change-quote into main

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,

  1. name: context:global "license": "Apache-2.0 patternType:standard fails to be parsed.
  2. Try to parse name: "context:global "license": "Apache-2.0 patternType:standard"
  3. The new YAML is parsed successfully with 2 mappings
    • name: "context:global "
    • license": ""Apache-2.0 patternType:standard"
  4. 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. Screen Shot 2022-08-16 at 09 58 29

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading