XML attributes not encoded correctly

Bug #779448 reported by Alistair Grant
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Appy
Fix Released
Undecided
Unassigned

Bug Description

appy 0.6.6 (pod) doesn't appear to be encoding XML attributes correctly.

The problem can be seen by creating a simple document with a hyperlink that includes multiple parameters, e.g. (from the .odt file):

Including a link: http://www.google.com.au/?q=python&likes=false (a valid, if meaningless URL)

<text:a xlink:type="simple" xlink:href="http://www.google.com.au/?q=python&amp;likes=false"><text:span text:style-name="T5">hyperlink which will fail</text:span></text:a>

The result document after rendering writes the link as:

<text:a xlink:type="simple" xlink:href="http://www.google.com.au/?q=python&likes=false"><text:span text:style-name="T5">hyperlink which will fail</text:span></text:a>

As can be seen, the original link contain "&amp;" in the url, while the rendered link contains "&".

Just to be clear, this is static text in the template, not variable substitution or odt chunk, etc.

I've also seen the problem when embedding images in to documents, but don't have an example. In this case angle brackets weren't being encoded.

I've attached the source document, and (hopefully) the python script and result document as well.

Thanks very much,
Alistair

Revision history for this message
Alistair Grant (akgrant0710) wrote :
Revision history for this message
Alistair Grant (akgrant0710) wrote :

Adding the conversion script.

Revision history for this message
Alistair Grant (akgrant0710) wrote :

Adding the result document.

Revision history for this message
Alistair Grant (akgrant0710) wrote :

I believe the fix is in dumpStartElement in buffers.py:

    def dumpStartElement(self, elem, attrs={}):
        self.write('<%s' % elem)
        for name, value in attrs.items():
            self.write(' %s=%s' % (name, quoteattr(value)))
# self.write(' %s="%s"' % (name, value))
        self.write('>')

With:

from xml.sax.saxutils import quoteattr

Near the start of the file.

Revision history for this message
Gaëtan Delannay (gaetan-delannay) wrote :

Hello Alistair,
I've committed your patch, sorry for the late answer, SO busy for the moment... !
http://bazaar.launchpad.net/~appy-dev/appy/trunk/revision/153
Does it work for you ?
Thanks
Gaetan

Changed in appy:
status: New → Fix Committed
Changed in appy:
milestone: none → 0.6.7
status: Fix Committed → Fix Released
Revision history for this message
Alistair Grant (akgrant0710) wrote : Re: [Bug 779448] Re: XML attributes not encoded correctly

Hi Gaetan,

Thanks for the follow-up. I've installed appy 0.6.7 and haven't had any
problems.

Thanks again,
Alistair

On 17/06/11 10:02, Gaëtan Delannay wrote:
> Hello Alistair,
> I've committed your patch, sorry for the late answer, SO busy for the moment... !
> http://bazaar.launchpad.net/~appy-dev/appy/trunk/revision/153
> Does it work for you ?
> Thanks
> Gaetan
>
> ** Changed in: appy
> Status: New => Fix Committed
>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.