Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-24539

Paged.js named strings are serialized with unmatched quotes in PDF Export (string-set content(text))

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 17.2.0
    • Export - PDF
    • None
    • Unknown

    Description

      XWiki PDF Export depends on PagedJS 0.4.3.

      <dependency>
        <groupId>org.webjars.npm</groupId>
        <artifactId>pagedjs</artifactId>
        <version>0.4.3</version>
      </dependency>
      

      Named string serialization is broken due to upstream Paged.js issue fixed by commit 60804ab but not present in any stable Paged.js release.

      How this shows up in XWiki

      If you set a StyleSheetExtension for CSS with on a pdf template with something like

      @media print {
        h2 {
          string-set: stringsetdebug content(text);
        }
      }

      and a minimal page for testing

      = Test Document =
      
      == Section One ==
      
      Some text.
      
      == Section Two ==
      
      Some more text. 

      and then use a web debugger to inspect the style of elements on the pdf rendered output , you can see the mismatch quotes 

      Actual: 

      --pagedjs-string-first-stringsetdebug: "Section One;
      --pagedjs-string-last-stringsetdebug: " Section Two;

      Expected:

      --pagedjs-string-first-stringsetdebug: "Section One";
      --pagedjs-string-last-stringsetdebug: "Section Two";

      I am seeing this on 17.2.0 on Windows but unless a mitigation is in place I'm not seeing, I expect it affects all versions that include PagedJS since the issue was introduced in 2020.

      I see this relates to  XWIKI-23726, but because it causes specific bad behavior I thought it was worth it's own bug.

      And yes, unfortunately I spent quite a while assuming the bug was in my own templates before tracing it down to the generated Paged.js output. 😅 Maybe this will save someone else some trouble.

      Attachments

        Activity

          People

            Unassigned Unassigned
            jameswartell James Wartell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: