#1 XML entity references are not encoded

closed
nobody
5
2007-12-08
2007-12-07
No

I have a record in my database which has an ampersand character '&' in it. Building the report seems to go ok, but when parsing the report for printing, it throws an exception. If I manually change the & to & in the .prp file, it parses ok.

I think the solution is to make sure that the XML is correctly escaped, and I'm attaching a patch which does that.

The exception which got thrown in the parser when generating the pdf:

Traceback (most recent call last):
File "PythonReports/pdf.py", line 435, in ?
run()
File "PythonReports/pdf.py", line 432, in run
write(_printout, _pdf)
File "PythonReports/pdf.py", line 420, in write
PdfWriter(report).write(filepath)
File "PythonReports/pdf.py", line 68, in __init__
self.report = prp.load(report)
File
"/home/bruce/projects/pythonreports/PythonReports-0.3.1/PythonReports/printout.py",
line 131, in load
_et.parse(source)
File
"/home/bruce/projects/pythonreports/PythonReports-0.3.1/PythonReports/datatypes.py",
line 1233, in parse
_root = ET.ElementTree.parse(self, source, parser)
File "<string>", line 32, in parse
SyntaxError: not well-formed (invalid token): line 3869, column 38

Line 3869 in the .prp was a <data> element which contained the '&' in it.

Discussion

  • Bruce Schultz

    Bruce Schultz - 2007-12-07

    Patch for the builder to escape data

     
  • Bruce Schultz

    Bruce Schultz - 2007-12-08

    Logged In: YES
    user_id=784165
    Originator: YES

    Yes, that solution works just as well :-)

    Thanks

     
  • Aleksandr Smyshliaev

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks