Re: BUG #4822: xmlattributes encodes '&' twice

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

"Itagaki Takahiro" <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp> writes:
> =# SELECT xmlelement(name a, xmlattributes('./qa?a=1&b=2' as href), 'Q&A');
> xmlelement
> --------------------------------------------
> <a href="./qa?a=1&amp;amp;b=2">Q&amp;A</a>
> (1 row)

> '&' in xmlattributes seems to be encoded twice.

This was apparently broken by Peter's patch here:
http://archives.postgresql.org/pgsql-committers/2009-04/msg00124.php

map_sql_value_to_xml_value() performs mapping of & (and various other
special characters), and evidently xmlTextWriterWriteAttribute() does
it again.

I'm not sure about the most appropriate solution. The libxml2
documentation is so awful that it doesn't even tell you that
xmlTextWriterWriteAttribute does that, let alone suggest whether there
is another API function that doesn't. We might have to add a bool flag
to map_sql_value_to_xml_value() to enable or disable mapping of special
characters.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message andri rahman hakim 2009-05-26 08:19:30 bug postgresql version 1.8.4
Previous Message Tom Lane 2009-05-25 17:34:41 Re: BUG #4823: problems downloading

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-05-25 19:02:47 Re: A couple of gripes about the gettext plurals patch
Previous Message Joshua Tolley 2009-05-25 18:29:21 Re: generic options for explain