HTML and PDF space export may fail with EmptyStackException

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • None
    • Affects Version/s: 7.19.17
    • None
    • 2
    • Severity 2 - Major
    • 1

      Problem

      Attempting to export a Confluence Space in PDF or HTML may fail with EmptyStackException

      Steps to Reproduce

      1. Create an empty Confluence page
      2. Set the below body in the bodycontent table for the page created at 1.
        <h3>Section</h3>
        <p>Some contnet.<br />
            <ac:emoticon ac:name="warning" /> Some more content
        </p>
        <p>placeholder...</p>
        <p>placeholder</p>
        <h3>placeholder</h3>
        <p>placeholder:
            <code>putKeyValue = function(key, value, <ac:link><ri:page ri:content-title="okCallback, errCallback" ri:space-key="TEST" /><ac:plain-text-link-body><![CDATA[okCallback, errCallback]]></ac:plain-text-link-body></ac:link>)</code>
        </p>
        <ac:parameter ac:name="title">placeholder</ac:parameter>
        <ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body>
            <![CDATA[kvs.putKeyValue("key", "value");
        ]]>
        </ac:plain-text-body>
        <h3>placeholder</h3>
        <p>placeholder</p>
        <p>placeholder
            <code>getKeyValue = function(key, dataCallback, <ac:link><ri:page ri:content-title="errCallback" ri:space-key="TEST" /><ac:plain-text-link-body><![CDATA[errCallback]]></ac:plain-text-link-body></ac:link>)</code>
        </p>
        <ac:parameter ac:name="title">placeholder</ac:parameter>
        <ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body>
            <![CDATA[// define the data callback
        var dataCallback = function(valuestring) {
            //work with valuestring
        };// get the value 
        kvs.getKeyValue("key", dataCallback);
        ]]>
        </ac:plain-text-body>  
      3. Flush Confluence cache
      4. Attempt the export the space where the page has been created either in PDF or HTML

      Expected Results

      Export succeeds.

      Actual Results

      The export fails and the following message is found in the logs:

      YYYY-MM-DD 12:48:13,729 ERROR \[Long running task: PDF Space Export] \[core.task.longrunning.AbstractLongRunningTask] lambda$doRunInternal$0 Error during PDF export
       \-\- url: /wiki/spaces/flyingpdf/doflyingpdf.action \| referer: https://server/wiki/spaces/flyingpdf/flyingpdf.action?key=TEST \| traceId: 589d888753988fbd \| userName: test \| action: doflyingpdf
      java.lang.RuntimeException: org.owasp.validator.html.ScanException: java.util.EmptyStackException
              at com.atlassian.confluence.content.render.xhtml.PolicyConfiguredCleaner.antiSamyClean(PolicyConfiguredCleaner.java:190\)
      

      The above failure is caused by the following block in the storage format:

      <ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body>
          <![CDATA[// define the data callback
      var dataCallback = function(valuestring) {
          //work with valuestring
      };// get the value 
      kvs.getKeyValue("key", dataCallback);
      ]]>
      </ac:plain-text-body>
      

      as the antiSamyClean code is removing the content from the CDATA element and causes the EmptyStackException.

      Workaround

      Exclude the page from the export or change the problematic entry in the body content of the page from:

      <ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body>
          <![CDATA[// define the data callback
      var dataCallback = function(valuestring) {
          //work with valuestring
      };// get the value 
      kvs.getKeyValue("key", dataCallback);
      ]]>
      </ac:plain-text-body>
      

      to

      <ac:parameter ac:name="language">javascript</ac:parameter><ac:plain-text-body>
       <code>
          <![CDATA[// define the data callback
      var dataCallback = function(valuestring) {
          //work with valuestring
      };// get the value 
      kvs.getKeyValue("key", dataCallback);
      ]]>
       </code>
      </ac:plain-text-body>
      

              Assignee:
              Unassigned
              Reporter:
              Marco Salvi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated: