Re: [HACKERS] BUG #4822: xmlattributes encodes '&' twice

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: [HACKERS] BUG #4822: xmlattributes encodes '&' twice
Date: 2009-06-09 22:06:39
Message-ID: 200906100106.40912.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sunday 31 May 2009 20:00:44 Tom Lane wrote:
> Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> > Here is a patch to fix the bug. I added a parameter 'encode' to
> > map_sql_value_to_xml_value() and pass false for xml attributes.
>
> One thing I was wondering about, which is sort of highlighted by your
> patch, is why is there the special exception for XML type in the
> existing code, and how does that interact with this behavior?

This is so that

xmlelement(name element, xml '<foo/>')

results in

<element><foo/></element>

and

xmlelement(name claim, text '1 < 2')

results in

<claim>1 &lt; 2</claim>

> Seems like there could be cases where we're getting one too many or too
> few encoding passes when the input is XML.

The patch doesn't actually change anything when the input datum is of type
XML. But anyway I have added a few regression test bits to make the
expectations more explicit.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2009-06-10 01:44:03 Re: BUG #4838: Database corruption after btree_gin index creation
Previous Message Peter Eisentraut 2009-06-09 22:01:29 Re: [HACKERS] BUG #4822: xmlattributes encodes '&' twice

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-06-09 22:11:18 Re: Problem with listen_addresses = '*' on 8.4beta2 on AIX
Previous Message Simon Riggs 2009-06-09 22:03:57 Re: postmaster recovery and automatic restart suppression