xpath does not seem to escape HTML correctly - Mailing list pgsql-sql

From John Lamb
Subject xpath does not seem to escape HTML correctly
Date
Msg-id CALr6pkhSe20gh5Hci1H=uT_7QE4av0m9h2eQMjqUX6D6AD9H1Q@mail.gmail.com
Whole thread Raw
Responses Re: xpath does not seem to escape HTML correctly
List pgsql-sql
I am parsing XML into a table using xpath and having issues with regards to the HTML encoded characters, it seems that some escaped HTML codes are being converted but others are not.
 
Prior to injection into XML the raw data is : !"£$%^&*()<>
 
The raw XML is as follows : <PLAN>!&quot;&#163;$%^&amp;*()&lt;&gt;</PLAN>
 
When I run this through xpath as suggested in the post below I find that some codes are converted and some aren't
 
select (xpath('/PLAN/text()', ('<PLAN>!&quot;&#163;$%^&amp;*()&lt;&gt;</PLAN>')::xml))[1]::text
 
The result is this : !"£$%^&amp;*()&lt;&gt;
 
It seems the &, < and > chars are not being handled but quote and GBP symbols are OK, when I run the query in the post below the "magic" and "toaster" works but I still get "s&amp;witch"
 
 
I am using PostgreSQL 9.3 on windows but see this behaivour on 9.1 on linux.
 
Does anyone have any ideas what the problem is here or do you think it's some kind of bug ?

pgsql-sql by date:

Previous
From: agharta
Date:
Subject: Re: Retrieve most recent 1 record from joined table
Next
From: David G Johnston
Date:
Subject: Re: xpath does not seem to escape HTML correctly