mirror of
https://github.com/postgres/postgres.git
synced 2025-11-06 07:49:08 +03:00
Convert xml_in to report errors softly.
The key idea here is that xml_parse must distinguish hard errors from soft errors. We want to throw a hard error for libxml initialization failures: those might be out-of-memory, or something else, but in any case they are not the fault of the input string. If we get to the point of parsing the input, and something goes wrong, we can fairly consider that to mean bad input. One thing that arguably does mean bad input, but I didn't trouble to handle softly, is encoding conversion failure while converting the server encoding to UTF8. This might be something to improve later, but it seems like a pretty low-probability scenario. Discussion: https://postgr.es/m/3564577.1671142683@sss.pgh.pa.us
This commit is contained in:
@@ -9,6 +9,13 @@ INSERT INTO xmltest VALUES (3, '<wrong');
|
||||
|
||||
SELECT * FROM xmltest;
|
||||
|
||||
-- test non-throwing API, too
|
||||
SELECT pg_input_is_valid('<value>one</value>', 'xml');
|
||||
SELECT pg_input_is_valid('<value>one</', 'xml');
|
||||
SELECT pg_input_error_message('<value>one</', 'xml');
|
||||
SELECT pg_input_is_valid('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
|
||||
SELECT pg_input_error_message('<?xml version="1.0" standalone="y"?><foo/>', 'xml');
|
||||
|
||||
|
||||
SELECT xmlcomment('test');
|
||||
SELECT xmlcomment('-test');
|
||||
|
||||
Reference in New Issue
Block a user