Re: BUG #4822: xmlattributes encodes '&' twice - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #4822: xmlattributes encodes '&' twice
Date
Msg-id 6200.1243276877@sss.pgh.pa.us
Whole thread Raw
In response to BUG #4822: xmlattributes encodes '&' twice  ("Itagaki Takahiro" <itagaki.takahiro@oss.ntt.co.jp>)
Responses Re: BUG #4822: xmlattributes encodes '&' twice
List pgsql-bugs
"Itagaki Takahiro" <itagaki.takahiro@oss.ntt.co.jp> writes:
> =# SELECT xmlelement(name a, xmlattributes('./qa?a=1&b=2' as href), 'Q&A');
>                  xmlelement
> --------------------------------------------
>  <a href="./qa?a=1&amp;b=2">Q&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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4823: problems downloading
Next
From: andri rahman hakim
Date:
Subject: bug postgresql version 1.8.4