Uploaded image for project: 'Apache Freemarker'
  1. Apache Freemarker
  2. FREEMARKER-115

Included file gets parsed (double ampersands converted)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.3.28
    • None
    • engine
    • None

    Description

      Using FMPP with FreeMarker to render a document. The main document resembles:

      <#assign updated = .now>
      <!doctype html>
      <html lang="en">
      <head>
        <meta charset="utf-8"/>
      </head>
      <body>
        <main>
          <article>
            <#include "includes/html/body.html" parse=false>
          </article>
        </main>
      </body>
      </html>
      

      The file includes/html/body.html contains:

      <div class="code">
      <pre><code>SCRIPT_DIR=&quot;\
        $(\
          cd &quot;$(dirname &quot;${BASH_SRC_DIR[0]}&quot;)&quot; \
          &gt;/dev/null 2&gt;&amp;1 \
          &amp;&amp; pwd\
        )&quot;
      SCRIPT_NAME=$(basename $0)</code></pre>
      </div>
      

      Note the  &𝗮𝗺𝗽; &𝗮𝗺𝗽;. When the main document is parsed by FreeMarker, the resulting document contains:

      <div class="code"><pre><code>SCRIPT_DIR="\
        $(\
          cd "$(dirname "${BASH_SRC_DIR[0]}")" \
          &gt;/dev/null 2&gt;&amp;1 \
          &amp;& pwd\
        )"
      SCRIPT_NAME=$(basename $0)</code></pre></div>
      

      Note the &𝗮𝗺𝗽; &, which is invalid HTML. The following line from the main document does not appear to prevent the engine from meddling with the contents, despite parse=false being set:

      <#include "includes/html/body.html" parse=false>
      

      The expected result, of course, is &𝗮𝗺𝗽;&𝗮𝗺𝗽; as per:

          &amp;&amp; pwd\
      

      A larger concern is that FreeMarker produced invalid HTML that wasn't caught in a unit test.

      Attachments

        Activity

          People

            Unassigned Unassigned
            DaveJarvis Dave Jarvis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: