Velocity
  1. Velocity
  2. VELOCITY-676

#[[##x]]# causes StringIndexOutOfBoundsException

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7
    • Fix Version/s: 1.7
    • Component/s: Engine
    • Labels:
      None

      Description

      The following VTL:

      #[#x]#

      Causes:

      Threw: class java.lang.StringIndexOutOfBoundsException
      Msg: String index out of range: -2
      java.lang.String.substring(String.java:1768)
      org.apache.velocity.runtime.parser.node.ASTTextblock.init(ASTTextblock.java:79)
      org.apache.velocity.runtime.parser.node.SimpleNode.init(SimpleNode.java:309)
      org.apache.velocity.Template.initDocument(Template.java:218)
      org.apache.velocity.Template.process(Template.java:126)

      1. velocity-676.patch
        2 kB
        Jarkko Viinamäki

        Activity

        Hide
        Jarkko Viinamäki added a comment -

        This should fix it.

        I changed the parser so that SINGLE_LINE_COMMENT_START is not detected in all states. The problem was the while IN_TEXTBLOCK state the parser ran into ## and processed SINGLE_LINE_COMMENT_START block which in turn somehow erased the input buffer.

        I hope this parser comment processing change doesn't break anything. Tests pass at least.

        Show
        Jarkko Viinamäki added a comment - This should fix it. I changed the parser so that SINGLE_LINE_COMMENT_START is not detected in all states. The problem was the while IN_TEXTBLOCK state the parser ran into ## and processed SINGLE_LINE_COMMENT_START block which in turn somehow erased the input buffer. I hope this parser comment processing change doesn't break anything. Tests pass at least.

          People

          • Assignee:
            Unassigned
            Reporter:
            Byron Foster
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development