BlueMountain created FOP-3173:
---------------------------------

             Summary: cannot include attachment whose name contains hash ('#') 
in the name
                 Key: FOP-3173
                 URL: https://issues.apache.org/jira/browse/FOP-3173
             Project: FOP
          Issue Type: Bug
          Components: fo/unqualified
    Affects Versions: 2.9
            Reporter: BlueMountain
         Attachments: PDFAttachmentTestCase.java

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)

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to