Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-3173

cannot include attachment whose name contains hash ('#') in the name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Bug
    • 2.9
    • None
    • fo/unqualified
    • None

    Description

      hi,

      we are relying on the fop to generate PDF given data held in database + file storage.
      we need to represent some ( file.name, file.data) as a pdf embedded attachment.

      some users have encountered issue when the file.name value carries hash sign ('#')

      upon generating the pdf, an exception is thrown about missing attachment name.

      I have added a new test to the  PDFAttachmentTestCase class (see attachment) to reproduce the issue.

      The added test that generates the error is:

      @Test
      public void testAddEmbeddedFileDash () throws IFException

      { PDFDocumentHandler docHandler = new PDFDocumentHandler(new IFContext(ua)); docHandler.setFontInfo(new FontInfo()); ByteArrayOutputStream out = new ByteArrayOutputStream(); docHandler.setResult(new StreamResult(out)); docHandler.startDocument(); docHandler.startPage(0, "", "", new Dimension()); docHandler.handleExtensionObject(new PDFEmbeddedFileAttachment("filename#1.txt", "src", "desc")); // issue occurs at this line *docHandler.getDocumentNavigationHandler().renderLink(new Link(* *new URIAction("embedded-file:filename#1.txt", false), new Rectangle()));* docHandler.endDocument(); }

       
      running the command: 

      mvn test -pl fop-core -Dtest=PDFAttachmentTestCase

      I get the following output:

      Running org.apache.fop.pdf.PDFAttachmentTestCase

      Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.15 sec <<< FAILURE! - in org.apache.fop.pdf.PDFAttachmentTestCase

      testAddEmbeddedFileDash(org.apache.fop.pdf.PDFAttachmentTestCase)  Time elapsed: 0.003 sec  <<< ERROR!

      java.lang.IllegalStateException: No embedded file with name filename present.

      at org.apache.fop.pdf.PDFFactory.getActionForEmbeddedFile(PDFFactory.java:728)

      at org.apache.fop.pdf.PDFFactory.getExternalAction(PDFFactory.java:600)

      at org.apache.fop.render.pdf.PDFDocumentNavigationHandler.getAction(PDFDocumentNavigationHandler.java:174)

      at org.apache.fop.render.pdf.PDFDocumentNavigationHandler.renderLink(PDFDocumentNavigationHandler.java:108)

      at org.apache.fop.pdf.PDFAttachmentTestCase.testAddEmbeddedFileDash(PDFAttachmentTestCase.java:119)

       

      Attachments

        1. PDFAttachmentTestCase.java
          6 kB
          BlueMountain

        Activity

          People

            Unassigned Unassigned
            bluemountain BlueMountain
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: