mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Ensure that xpath() escapes special characters in string values.
Without this it's possible for the output to not be legal XML, as illustrated by the added regression test cases. NB: this change will need to be called out as an incompatibility in the 9.2 release notes, since it's possible somebody was relying on the old behavior, even though it's clearly wrong. Florian Pflug, reviewed by Radoslaw Smogura
This commit is contained in:
@@ -175,6 +175,8 @@ SELECT xpath('', '<!-- error -->');
|
||||
SELECT xpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
|
||||
SELECT xpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc', 'http://127.0.0.1']]);
|
||||
SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
|
||||
SELECT xpath('//text()', '<root><</root>');
|
||||
SELECT xpath('//@value', '<root value="<"/>');
|
||||
|
||||
-- Test xmlexists and xpath_exists
|
||||
SELECT xmlexists('//town[text() = ''Toronto'']' PASSING BY REF '<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>');
|
||||
|
||||
Reference in New Issue
Block a user