Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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

pgsql-hackers by date

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

pgsql-bugs by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group