[jira] [Comment Edited] (FOP-3173) cannot include attachment whose name contains hash ('#') in the name

2024-04-03 Thread BlueMountain (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-3173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833714#comment-17833714
 ] 

BlueMountain edited comment on FOP-3173 at 4/3/24 6:50 PM:
---

hi peter,

thank you for your prompt reply.

i actually made the test case work using ...

```
{color:#9e880d}@Test{color}{color:#0033b3}public void 
{color}{color:#00627a}testAddEmbeddedFileDash {color}() {color:#0033b3}throws 
{color}{color:#00}IFException {color}{
{color:#00}  PDFDocumentHandler docHandler {color}= {color:#0033b3}new 
{color}PDFDocumentHandler({color:#0033b3}new 
{color}IFContext({color:#871094}ua{color}));
{color:#00}  docHandler{color}.setFontInfo({color:#0033b3}new 
{color}FontInfo());
{color:#00}  ByteArrayOutputStream out {color}= {color:#0033b3}new 
{color}ByteArrayOutputStream();
{color:#00}  docHandler{color}.setResult({color:#0033b3}new 
{color}StreamResult({color:#00}out{color}));
{color:#00}  docHandler{color}.startDocument();
{color:#00}  docHandler{color}.startPage({color:#1750eb}0{color}, 
{color:#067d17}""{color}, {color:#067d17}""{color}, {color:#0033b3}new 
{color}Dimension());
{color:#00}  String unicodeFilename {color}= 
{color:#067d17}"filename#1.txt"{color};
{color:#00}  docHandler{color}.handleExtensionObject(
    {color:#0033b3}new   
{color}PDFEmbeddedFileAttachment({color:#00}unicodeFilename{color}, 
{color:#067d17}"src"{color}, {color:#067d17}"desc"{color})
  );
  *{color:#8c8c8c}// if the file name contains characters that are 
considered{color}{color:#8c8c8c}  // as fragment or query, the 
'embedded-[file:$|file:///$]{filename}{color}{color:#8c8c8c}  // will fail at 
returning the actual file name{color}{color:#8c8c8c}  // we are relying, here, 
on the URI to perform actual{color}{color:#8c8c8c}  // character 
conversion{color}{color:#8c8c8c}  {color}{color:#0033b3}final 
{color}{color:#00}String uri{color};*
  *{color:#0033b3}try {color}{*
    *{color:#00}URI tmp {color}= {color:#0033b3}new {color}URI 
({color:#067d17}"embedded-file"{color}, {color:#00}unicodeFilename{color}, 
{color:#0033b3}null{color});*
    *{color:#00}uri {color}= {color:#00}tmp{color}.toString ();*
  *}*
  *{color:#0033b3}catch {color}({color:#00}URISyntaxException e{color}) {*
    *{color:#0033b3}throw new {color}IllegalStateException 
({color:#00}e{color});*
  *}*
{color:#00}  docHandler{color}.getDocumentNavigationHandler().renderLink(
{color:#0033b3}    new {color}Link({color:#0033b3}new 
{color}URIAction({*}{color:#00}uri{color}{*}, {color:#0033b3}false{color}), 
{color:#0033b3}new {color}Rectangle())
  );
{color:#00}  docHandler{color}.endDocument();
}
```

but actually, even doing some change in the original program to test the file, 
i was still getting errors.

the way embedded content was used in pdf was:
1- include it in the list of pdf attachments
2- include in the page, 1 link for each embedded attachment.

in order to allow access to these attachments either browsing the document, 
page by page ... or accessing directly the list of pdf embedded files from the 
pdf viewer application.

the fop was looking like:

```
{color:#00} {color}{color:#80}
...{color}
{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}
...

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}
{color}```

the reported error was dumping stack trace that was carying:
java.lang.IllegalStateException: {+}No embedded file with name *error* 
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.render.intermediate.IFRenderer.renderPage(IFRenderer.java:594)
    at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:123)

i was thinking the issue was comming from the  and it's 
filename ...
but the actual cause of the error was the link:

```

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}
{color}```

i was able to correct the problem, by generating ...

```

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}
{color}```

i therefore guess the issue can be closed:
{*}Q{*}: shall i close it 

[jira] [Commented] (FOP-3173) cannot include attachment whose name contains hash ('#') in the name

2024-04-03 Thread BlueMountain (Jira)


[ 
https://issues.apache.org/jira/browse/FOP-3173?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17833714#comment-17833714
 ] 

BlueMountain commented on FOP-3173:
---

hi peter,

thank you for your prompt reply.

i actually made the test case work using ...

```
{color:#9e880d}@Test
{color}{color:#0033b3}public void {color}{color:#00627a}testAddEmbeddedFileDash 
{color}() {color:#0033b3}throws {color}{color:#00}IFException {color}{
{color:#00}  PDFDocumentHandler docHandler {color}= {color:#0033b3}new 
{color}PDFDocumentHandler({color:#0033b3}new 
{color}IFContext({color:#871094}ua{color}));
{color:#00}  docHandler{color}.setFontInfo({color:#0033b3}new 
{color}FontInfo());
{color:#00}  ByteArrayOutputStream out {color}= {color:#0033b3}new 
{color}ByteArrayOutputStream();
{color:#00}  docHandler{color}.setResult({color:#0033b3}new 
{color}StreamResult({color:#00}out{color}));
{color:#00}  docHandler{color}.startDocument();
{color:#00}  docHandler{color}.startPage({color:#1750eb}0{color}, 
{color:#067d17}""{color}, {color:#067d17}""{color}, {color:#0033b3}new 
{color}Dimension());
{color:#00}  String unicodeFilename {color}= 
{color:#067d17}"filename#1.txt"{color};
{color:#00}  docHandler{color}.handleExtensionObject(
    {color:#0033b3}new   
{color}PDFEmbeddedFileAttachment({color:#00}unicodeFilename{color}, 
{color:#067d17}"src"{color}, {color:#067d17}"desc"{color})
  );
  *{color:#8c8c8c}// if the file name contains characters that are considered
{color}{color:#8c8c8c}  // as fragment or query, the 'embedded-file:${filename}
{color}{color:#8c8c8c}  // will fail at returning the actual file name
{color}{color:#8c8c8c}  // we are relying, here, on the URI to perform actual
{color}{color:#8c8c8c}  // character conversion
{color}{color:#8c8c8c}  {color}{color:#0033b3}final 
{color}{color:#00}String uri{color};*
  *{color:#0033b3}try {color}{*
    *{color:#00}URI tmp {color}= {color:#0033b3}new {color}URI 
({color:#067d17}"embedded-file"{color}, {color:#00}unicodeFilename{color}, 
{color:#0033b3}null{color});*
    *{color:#00}uri {color}= {color:#00}tmp{color}.toString ();*
  *}*
  *{color:#0033b3}catch {color}({color:#00}URISyntaxException e{color}) {*
    *{color:#0033b3}throw new {color}IllegalStateException 
({color:#00}e{color});*
  *}*
{color:#00}  docHandler{color}.getDocumentNavigationHandler().renderLink(
{color:#0033b3}    new {color}Link({color:#0033b3}new 
{color}URIAction({*}{color:#00}uri{color}{*}, {color:#0033b3}false{color}), 
{color:#0033b3}new {color}Rectangle())
  );
{color:#00}  docHandler{color}.endDocument();
}```

but actually, even doing some change in the original program to test the file, 
i was still getting errors.

the way embedded content was used in pdf was:
1- include it in the list of pdf attachments
2- include in the page, 1 link for each embedded attachment.

in order to allow access to these attachments either browsing the document, 
page by page ... or accessing directly the list of pdf embedded files from the 
pdf viewer application.

the fop was looking like:

```

{color:#00} {color}{color:#80}
...
{color}
{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}
...

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}```

the reported error was dumping stack trace that was carying:
java.lang.IllegalStateException: {+}No embedded file with name *error* 
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.render.intermediate.IFRenderer.renderPage(IFRenderer.java:594)
    at org.apache.fop.area.RenderPagesModel.addPage(RenderPagesModel.java:123)

i was thinking the issue was comming from the  and it's 
filename ...
but the actual cause of the error was the link:

```

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}```

i was able to correct the problem, by generating ...

```

{color:#00} {color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}{color:#00}error#1.log{color}{color:#80}{color}
{color:#00} {color}{color:#80}{color}```

i therefore guess the issue can be closed:
{*}Q{*}: shall i close it myself ?

note: however, it would be good to keep some test 

[jira] [Assigned] (FOP-3172) image-loading configuration settings are not thread-safe

2024-04-03 Thread Simon Steiner (Jira)


 [ 
https://issues.apache.org/jira/browse/FOP-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Simon Steiner reassigned FOP-3172:
--

Assignee: Simon Steiner

> image-loading configuration settings are not thread-safe
> 
>
> Key: FOP-3172
> URL: https://issues.apache.org/jira/browse/FOP-3172
> Project: FOP
>  Issue Type: Bug
>  Components: image/unqualified
>Affects Versions: 2.9
>Reporter: Martin Leitner
>Assignee: Simon Steiner
>Priority: Major
> Attachments: fop_3172.zip
>
>
> As a workaround for FOP-3171 I added an  section to the config 
> and noticed that the settings will take effect on all subsequent renderings 
> in the same VM, even when they use a different config or none at all. When 
> running two or more rendering processes with different configs in parallel, 
> the result will basically be random.
> At the very least, this behaviour should be documented and warned about.



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