Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6916

Using markup in a GString causes a stack overflow

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.3
    • 2.3.4
    • Templating
    • None

    Description

      In a markup template, if you write something like:

      p "This is a ${strong('bold text')}"
      

      the user will assume that the output is:

      <p>This is a <strong>bold text</strong>/</p>
      

      However, the markup builder is a streaming builder, so calling a method in a GString results in a direct rendering to the output. At best, it will trigger a NPE, or a stack overflow.

      I suggest to add the following notation to allow that kind of code:

      p "This is a ${$strong('bold text')}"
      

      The inner tag is preceded with a dollar($) sign, which tells the markup engine that the call should be rendered as a string. It would be a shortcut notation for:

      p "This is a ${stringOf { strong('bold text') } }"
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: