Uploaded image for project: 'Velocity'
  1. Velocity
  2. VELOCITY-587

Backslashes throw lexical errors in double-quoted strings

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.6
    • Fix Version/s: 1.6
    • Component/s: None
    • Labels:
      None

      Description

      The VTL doesn't currently provide a way to express strings containing a single backslash ()

      #set($backslash="\")

      results in a lexical error during template parsing.

      #set($backslash="
      ")

      results in $backslash being assigned a string containing two backslashes (
      )

      It appears the only workaround available now is to construct a variable containing just a single backslash with this idiom:

      #set($twobackslashes="
      ")
      #set($backslash=$twobackslashes.substring(0,1))

      Even if this can't be fixed in the parser, the documentation should be updated to define a preferred idiom for obtaining a string containing a single backslash.

      jon.

      note: this issue partially duplicates a comment by Guido Deinhammer on issue #454 regarding other escaping issues. I have raised a separate issue, so that this one can be addressed separately, if desired.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jon.seymour Jon Seymour
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: