aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/xml.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2014-09-09 11:34:52 -0400
committerPeter Eisentraut <peter_e@gmx.net>2014-09-09 11:34:52 -0400
commit57b1085df55d092e2a728043ec607db8fdef2483 (patch)
tree4709af218a0c32a4c748ca997accd4d64759c30d /src/backend/utils/adt/xml.c
parentf0051c1a142ecaff7828b87315c26c7acbf8e583 (diff)
downloadpostgresql-57b1085df55d092e2a728043ec607db8fdef2483.tar.gz
postgresql-57b1085df55d092e2a728043ec607db8fdef2483.zip
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>
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r--src/backend/utils/adt/xml.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c
index 422be69bd6d..119dfc7efec 100644
--- a/src/backend/utils/adt/xml.c
+++ b/src/backend/utils/adt/xml.c
@@ -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();