Uploaded image for project: 'Configuration Persistence Service'
  1. Configuration Persistence Service
  2. CPS-345

Leaf String value comparison matches mix of single and double quotes

XMLWordPrintable

      The RegEx pattern for leaf value comparison does not checks the surrounding quotes are the same. 

      Current Expression: ['\"](.*)['\"] (see org/onap/cps/spi/query/CpsPathQuery.java)

      some examples of the extracted comparison value using this expression

      "abc" -> abc  -> correct
      'abc' -> abc -> correct
      "abc' -> abc -> Incorrect, should throw exception
      "quote's" -> quote's - correct (this surprised me, but because it use a greedy quantifier it actually works OK

      Bug is only very minor but could be good for a new starter to resolve:

      Suggestion for solution 1:

      use 2 different regex 

      LEAF_STRING_VALUE_IN_SINGLE_QUOTES_PATTERN  
      LEAF_STRING_VALUE_IN_DOUBLE_QUOTES_PATTERN  

      Suggestion for solution 1:

       have a regex that accept both pairs using 2 groups: '(.)'|"(.)"

      then the comparison value needs to be the concatenation of both groups (one of which will always be empty.

      As part of this bugs more tests need too be added to org/onap/cps/spi/query/CpsPathQuerySpec.groovy to cover these cases

            shivasubedi shivasubedi
            ToineSiebelink Toine Siebelink
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: