groovy
  1. groovy
  2. GROOVY-675

multiple backslashes and backslash plus dollarsign are not correctly interpreted

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-beta-8
    • Fix Version/s: 1.0-beta-10
    • Component/s: ast builder, lexer, parser
    • Labels:
      None
    • Number of attachments :
      4

      Description

      the folowing lines are failing

      assert "\\$"=="
      "+"$"
      assert "\\\\"=="\\"+"
      "

      but the following are not

      assert "
      $"=="$"
      assert "\\\\"=="
      "
      assert "\\\\\\"=="\\"+"
      "
      assert "\\\\\\\\"=="\\"+"
      "
      assert "\\\\\\\\\\"=="\\""\\""
      "
      assert "\\\\\\\\\\\\"=="\\""\\""
      "

      2 backslashes are reduced to just one backslash, and the dollar sign seems to "consume" the leading backslash

      1. changes.txt
        5 kB
        Kim, Pilho
      2. Groovy675_Bug.groovy
        1.0 kB
        Kim, Pilho
      3. GROOVY675Test.groovy
        0.9 kB
        Kim, Pilho
      4. StringLexer.diff.txt
        2 kB
        Kim, Pilho

        Activity

        Hide
        blackdrag blackdrag added a comment -

        typo corrected

        Show
        blackdrag blackdrag added a comment - typo corrected
        Hide
        Kim, Pilho added a comment -

        The attached file will fix such a bug
        for strings containing backslash character().

        Show
        Kim, Pilho added a comment - The attached file will fix such a bug for strings containing backslash character().
        Hide
        Kim, Pilho added a comment -

        The above patch is incomplete yet,
        cause of "\"", "
        "+"A", and etc.

        Show
        Kim, Pilho added a comment - The above patch is incomplete yet, cause of "\"", " "+"A", and etc.
        Hide
        Kim, Pilho added a comment -

        Ignore GROOVY675Test.groovy and StringLexer.diff.txt

        I have attached two files
        changes.txt and Groovy675_Bug.groovy
        to fix two issues GROOVY-675 and GROOVY-700.

        This fix have passed also the test scripts:
        EscapedMetaCharacterTest.groovy
        Base64Test.groovy
        DollarEscapingTest.groovy

        Examples)
        x = 2+3
        println "A\\\\ $

        {x}" # Output: A
        5
        println 'A\\\\ ${x}

        ' # Output: A
        $

        {x}
        println "A\\\\ \${x}

        " # Output: A
        $

        {x}

        println "
        " # Output: \
        println "\"" # Output: "
        println "\\\"\\\\" # Output: \"

        Show
        Kim, Pilho added a comment - Ignore GROOVY675Test.groovy and StringLexer.diff.txt I have attached two files changes.txt and Groovy675_Bug.groovy to fix two issues GROOVY-675 and GROOVY-700 . This fix have passed also the test scripts: EscapedMetaCharacterTest.groovy Base64Test.groovy DollarEscapingTest.groovy Examples) x = 2+3 println "A\\\\ $ {x}" # Output: A 5 println 'A\\\\ ${x} ' # Output: A $ {x} println "A\\\\ \${x} " # Output: A $ {x} println " " # Output: \ println "\"" # Output: " println "\\\"\\\\" # Output: \"
        Hide
        Kim, Pilho added a comment -

        It is possible to handle strings and gstrings which contain meta characters
        and/or $.
        This fixes the issue GROOVY-700, too.

        Show
        Kim, Pilho added a comment - It is possible to handle strings and gstrings which contain meta characters and/or $. This fixes the issue GROOVY-700 , too.

          People

          • Assignee:
            james strachan
            Reporter:
            blackdrag blackdrag
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: