Apostrophe handling in CpsPathParser 74/135474/7
authordanielhanrahan <daniel.hanrahan@est.tech>
Wed, 28 Jun 2023 11:55:20 +0000 (12:55 +0100)
committerdanielhanrahan <daniel.hanrahan@est.tech>
Thu, 20 Jul 2023 09:08:50 +0000 (10:08 +0100)
commit74a47154f3bce495d9f58a300a860d750ae309f1
tree5567ea2e3e53c1867f5db94a49edc31505ea658d
parent6a2eca2859d8b2ab88ff04663902eb7cc74b4fc1
Apostrophe handling in CpsPathParser

Apostrophe is not currently handled correctly, and having apostrophe in
the xpath will lead to various errors.
For example, normalizing this xpath works:
  /path[@name="I'm quoted"] -> /path[@name='I\'m quoted']
However the resulting xpath will throw a PathParsingException if parsed!
(Thus path normalization is not idempotent.)

- Use '' for escaping apostrophe in single quoted leaf value,
  to comply with XPath standard (and use "" for escaping in ").
- Use Liquibase to make existing data comply with new rules.
- Leaf values in data leaves are now unescaped, e.g. "I'm quoted"
- Quoting is now consistent for leaf/text/contains conditions.

Issue-ID: CPS-1769
Signed-off-by: danielhanrahan <daniel.hanrahan@est.tech>
Change-Id: Iafc287f738254d7f99706c6bc548091c0ecd5aa0
15 files changed:
cps-path-parser/src/main/antlr4/org/onap/cps/cpspath/parser/antlr4/CpsPath.g4
cps-path-parser/src/main/java/org/onap/cps/cpspath/parser/CpsPathBuilder.java
cps-path-parser/src/test/groovy/org/onap/cps/cpspath/parser/CpsPathQuerySpec.groovy
cps-ri/src/main/java/org/onap/cps/spi/repository/FragmentQueryBuilder.java
cps-ri/src/main/java/org/onap/cps/spi/repository/TempTableCreator.java
cps-ri/src/main/java/org/onap/cps/spi/utils/EscapeUtils.java
cps-ri/src/main/resources/changelog/changelog-master.yaml
cps-ri/src/main/resources/changelog/db/changes/21-escape-quotes-in-xpath-forward.sql [new file with mode: 0644]
cps-ri/src/main/resources/changelog/db/changes/21-escape-quotes-in-xpath-rollback.sql [new file with mode: 0644]
cps-ri/src/main/resources/changelog/db/changes/21-escape-quotes-in-xpath.yaml [new file with mode: 0644]
cps-ri/src/test/groovy/org/onap/cps/spi/utils/EscapeUtilsSpec.groovy
cps-service/src/main/java/org/onap/cps/utils/YangUtils.java
docs/cps-path.rst
docs/release-notes.rst
integration-test/src/test/groovy/org/onap/cps/integration/functional/CpsQueryServiceIntegrationSpec.groovy