mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Allow empty content in xml type
The xml type previously rejected "content" that is empty or consists only of spaces. But the SQL/XML standard allows that, so change that. The accepted values for XML "documents" are not changed. Reviewed-by: Ali Akbar <the.apaan@gmail.com>
This commit is contained in:
@ -1400,11 +1400,15 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace,
|
||||
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
|
||||
doc->standalone = standalone;
|
||||
|
||||
res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
|
||||
utf8string + count, NULL);
|
||||
if (res_code != 0 || xmlerrcxt->err_occurred)
|
||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT,
|
||||
"invalid XML content");
|
||||
/* allow empty content */
|
||||
if (*(utf8string + count))
|
||||
{
|
||||
res_code = xmlParseBalancedChunkMemory(doc, NULL, NULL, 0,
|
||||
utf8string + count, NULL);
|
||||
if (res_code != 0 || xmlerrcxt->err_occurred)
|
||||
xml_ereport(xmlerrcxt, ERROR, ERRCODE_INVALID_XML_CONTENT,
|
||||
"invalid XML content");
|
||||
}
|
||||
}
|
||||
}
|
||||
PG_CATCH();
|
||||
|
Reference in New Issue
Block a user