Issue 249 in xdocreport: Text is not escaped before inserting into xml

85 views
Skip to first unread message

xdocr...@googlecode.com

unread,
Apr 21, 2013, 10:39:09 PM4/21/13
to xdocr...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 249 by markcdes...@gmail.com: Text is not escaped before
inserting into xml
http://code.google.com/p/xdocreport/issues/detail?id=249

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.


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

xdocr...@googlecode.com

unread,
Apr 22, 2013, 3:13:29 AM4/22/13
to xdocr...@googlegroups.com
Updates:
Status: Accepted
Owner: angelo.z...@gmail.com

Comment #1 on issue 249 by angelo.z...@gmail.com: Text is not escaped
XDocReport should do that. Could you attach please your docx + java code
which causes the problem please.

Many thank's

Regards Angelo

xdocr...@googlecode.com

unread,
Apr 24, 2013, 12:42:23 AM4/24/13
to xdocr...@googlegroups.com

Comment #2 on issue 249 by markcdes...@gmail.com: Text is not escaped
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

Attachments:
WordXMLEscTest.java 1.0 KB

xdocr...@googlecode.com

unread,
Apr 24, 2013, 8:57:15 AM4/24/13
to xdocr...@googlegroups.com

Comment #3 on issue 249 by angelo.z...@gmail.com: Text is not escaped
Hi,

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

Regards Angelo

xdocr...@googlecode.com

unread,
Apr 24, 2013, 9:00:16 AM4/24/13
to xdocr...@googlegroups.com

Comment #4 on issue 249 by markcdes...@gmail.com: Text is not escaped
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.


Attachments:
XMLEscapeTest.docx 25.2 KB

xdocr...@googlecode.com

unread,
Apr 24, 2013, 9:57:26 AM4/24/13
to xdocr...@googlegroups.com

Comment #5 on issue 249 by angelo.z...@gmail.com: Text is not escaped
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

xdocr...@googlecode.com

unread,
Apr 24, 2013, 8:08:23 PM4/24/13
to xdocr...@googlegroups.com

Comment #6 on issue 249 by markcdes...@gmail.com: Text is not escaped
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

xdocr...@googlecode.com

unread,
Apr 24, 2013, 8:10:14 PM4/24/13
to xdocr...@googlegroups.com

Comment #7 on issue 249 by markcdes...@gmail.com: Text is not escaped
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>

xdocr...@googlecode.com

unread,
Sep 17, 2013, 12:06:29 PM9/17/13
to xdocr...@googlegroups.com

Comment #8 on issue 249 by angelo.z...@gmail.com: Text is not escaped
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

xdocr...@googlecode.com

unread,
Sep 17, 2013, 9:01:35 PM9/17/13
to xdocr...@googlegroups.com

Comment #9 on issue 249 by markcdes...@gmail.com: Text is not escaped
Hi Angelo,

You can close the ticket.

Cheers,
Mark

xdocr...@googlecode.com

unread,
Sep 18, 2013, 3:21:46 AM9/18/13
to xdocr...@googlegroups.com
Updates:
Status: Invalid

Comment #10 on issue 249 by angelo.z...@gmail.com: Text is not escaped
Ok Thank's Mark. I close this issue.
Reply all
Reply to author
Forward
0 new messages