dbarra / xdocreport

Automatically exported from code.google.com/p/xdocreport
1 stars 0 forks source link

Text is not escaped before inserting into xml #249

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Create a field in word document
2. Set the value of the field to be "foo & bar"
3. Run report to produce a word document
4. Open the report in Word, and a error will be generated complaining of 
invalid characters

What is the expected output? What do you see instead?

It would be nice if xdocreport, before inserting the value into the word 
document escaped all invalid characters (&, <, > etc).

Please provide any additional information below.

Whilst this problem can be manually worked around by changing the value to be 
"foo &amp; bar", this defeats the purpose of templating where the model should 
not care what the template format is.

Original issue reported on code.google.com by markcdes...@gmail.com on 22 Apr 2013 at 2:38

GoogleCodeExporter commented 8 years ago
XDocReport should do that. Could you attach please your docx + java code which 
causes the problem please.

Many thank's

Regards Angelo

Original comment by angelo.z...@gmail.com on 22 Apr 2013 at 7:13

GoogleCodeExporter commented 8 years ago
Hi Angelo,

Sorry for the delayed response. Attached is a word doc, and below is the code 
used to generate the error. I'm using xdoc reports v.1.0.0 & freemarker 2.3.19

import fr.opensagres.xdocreport.document.IXDocReport;
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.freemarker.FreemarkerTemplateEngine;
import 
fr.opensagres.xdocreport.template.freemarker.internal.XDocFreemarkerContext;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import org.testng.annotations.Test;

public class WordXMLEscTest {
    @Test
    public void testEsc() throws Exception {
        FreemarkerTemplateEngine engine = new FreemarkerTemplateEngine();
        URL templateURL = this.getClass().getResource("/templates/XMLEscapeTest.docx");
        InputStream in = templateURL.openStream();
        IXDocReport report = XDocReportRegistry.getRegistry().loadReport(in, engine);

        XDocFreemarkerContext context = new XDocFreemarkerContext();
        context.put("account", "Mark & Co");
        report.process(context, new FileOutputStream("/tmp/output.docx"));
    }
}

Regards,
Mark

Original comment by markcdes...@gmail.com on 24 Apr 2013 at 4:42

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

Could you attach please you docx. Many thank's.
Just one question , do you use megefield?

Regards Angelo

Original comment by angelo.z...@gmail.com on 24 Apr 2013 at 12:57

GoogleCodeExporter commented 8 years ago
Opps sorry looks like I attached the source as opposed to the template file.

Attached is the word doc and yes I am using a merge field.

Original comment by markcdes...@gmail.com on 24 Apr 2013 at 1:00

Attachments:

GoogleCodeExporter commented 8 years ago
Ok thank's. 

Your problem is very strange because we use XML escape feature with FM 
(http://freemarker.sourceforge.net/docs/xgui_imperative_learn.html) 

I have tried quicly tested your docx with our online demo 
http://xdocreport.opensagres.cloudbees.net/processReport.jsp and it works?

I will try it with a simple Java main.

Have you tried with XDocReport v.1.0.1?

Regards Angelo

Original comment by angelo.z...@gmail.com on 24 Apr 2013 at 1:57

GoogleCodeExporter commented 8 years ago
Now this is strange. I ran the report on 
http://xdocreport.opensagres.cloudbees.net/processReport.jsp and yes it did 
work fine.

My questions are:

1) Is the cloudbees application running 1.0.1 or 1.0.0? I am testing on 1.0.0 
as 1.0.1 does not seem to be released yet.

2) Is the source for the cloudbees application available. It would be 
interesting to see how it differs from my code, which I thought would have been 
reasonably boiler plate.

Regards,
Mark

Original comment by markcdes...@gmail.com on 25 Apr 2013 at 12:08

GoogleCodeExporter commented 8 years ago
Below are the maven dependancies that I am using.

      <dependency>
          <groupId>org.freemarker</groupId>
          <artifactId>freemarker</artifactId>
          <version>2.3.19</version>
      </dependency>
      <dependency>
          <groupId>fr.opensagres.xdocreport</groupId>
          <artifactId>fr.opensagres.xdocreport.document.docx</artifactId>
          <version>1.0.0</version>
      </dependency>
      <dependency>
          <groupId>fr.opensagres.xdocreport</groupId>
          <artifactId>fr.opensagres.xdocreport.template.freemarker</artifactId>
          <version>1.0.0</version>
      </dependency> 

Original comment by markcdes...@gmail.com on 25 Apr 2013 at 12:10

GoogleCodeExporter commented 8 years ago
Hi Mark,

Have you tried your problem with last version of XDocReport (1.0.2 released and 
1.0.3 not released).

I would like to close this issue.

Thank's for your test.

Regards Angelo

Original comment by angelo.z...@gmail.com on 17 Sep 2013 at 4:06

GoogleCodeExporter commented 8 years ago
Hi Angelo,

You can close the ticket.

Cheers,
Mark

Original comment by markcdes...@gmail.com on 18 Sep 2013 at 1:01

GoogleCodeExporter commented 8 years ago
Ok Thank's Mark. I close this issue.

Original comment by angelo.z...@gmail.com on 18 Sep 2013 at 7:21