@@ -1688,8 +1688,8 @@ xml_doctype_in_content(const xmlChar *str)
1688
1688
* xmloption_arg, but a DOCTYPE node in the input can force DOCUMENT mode).
1689
1689
*
1690
1690
* If parsed_nodes isn't NULL and the input is not an XML document, the list
1691
- * of parsed nodes from the xmlParseInNodeContext call will be returned to
1692
- * *parsed_nodes.
1691
+ * of parsed nodes from the xmlParseBalancedChunkMemory call will be returned
1692
+ * to *parsed_nodes.
1693
1693
*
1694
1694
* Errors normally result in ereport(ERROR), but if escontext is an
1695
1695
* ErrorSaveContext, then "safe" errors are reported there instead, and the
@@ -1795,7 +1795,7 @@ xml_parse(text *data, XmlOptionType xmloption_arg,
1795
1795
doc = xmlCtxtReadDoc (ctxt , utf8string ,
1796
1796
NULL ,
1797
1797
"UTF-8" ,
1798
- XML_PARSE_NOENT | XML_PARSE_DTDATTR | XML_PARSE_HUGE
1798
+ XML_PARSE_NOENT | XML_PARSE_DTDATTR
1799
1799
| (preserve_whitespace ? 0 : XML_PARSE_NOBLANKS ));
1800
1800
if (doc == NULL || xmlerrcxt -> err_occurred )
1801
1801
{
@@ -1828,30 +1828,10 @@ xml_parse(text *data, XmlOptionType xmloption_arg,
1828
1828
/* allow empty content */
1829
1829
if (* (utf8string + count ))
1830
1830
{
1831
- const char * data ;
1832
- xmlNodePtr root ;
1833
- xmlNodePtr lst ;
1834
- xmlParserErrors xml_error ;
1835
-
1836
- data = (const char * ) (utf8string + count );
1837
-
1838
- /*
1839
- * Create a fake root node. The xmlNewDoc() function creates
1840
- * an XML document without any nodes, and this is required for
1841
- * xmlParseInNodeContext() that is able to handle
1842
- * XML_PARSE_HUGE.
1843
- */
1844
- root = xmlNewNode (NULL , (const xmlChar * ) "content-root" );
1845
- if (root == NULL || xmlerrcxt -> err_occurred )
1846
- xml_ereport (xmlerrcxt , ERROR , ERRCODE_OUT_OF_MEMORY ,
1847
- "could not allocate xml node" );
1848
- xmlDocSetRootElement (doc , root );
1849
-
1850
- /* Try to parse string with using root node context. */
1851
- xml_error = xmlParseInNodeContext (root , data , strlen (data ),
1852
- XML_PARSE_HUGE ,
1853
- parsed_nodes ? parsed_nodes : & lst );
1854
- if (xml_error != XML_ERR_OK || xmlerrcxt -> err_occurred )
1831
+ res_code = xmlParseBalancedChunkMemory (doc , NULL , NULL , 0 ,
1832
+ utf8string + count ,
1833
+ parsed_nodes );
1834
+ if (res_code != 0 || xmlerrcxt -> err_occurred )
1855
1835
{
1856
1836
xml_errsave (escontext , xmlerrcxt ,
1857
1837
ERRCODE_INVALID_XML_CONTENT ,
@@ -4364,7 +4344,7 @@ xpath_internal(text *xpath_expr_text, xmltype *data, ArrayType *namespaces,
4364
4344
xml_ereport (xmlerrcxt , ERROR , ERRCODE_OUT_OF_MEMORY ,
4365
4345
"could not allocate parser context" );
4366
4346
doc = xmlCtxtReadMemory (ctxt , (char * ) string + xmldecl_len ,
4367
- len - xmldecl_len , NULL , NULL , XML_PARSE_HUGE );
4347
+ len - xmldecl_len , NULL , NULL , 0 );
4368
4348
if (doc == NULL || xmlerrcxt -> err_occurred )
4369
4349
xml_ereport (xmlerrcxt , ERROR , ERRCODE_INVALID_XML_DOCUMENT ,
4370
4350
"could not parse XML document" );
@@ -4695,7 +4675,7 @@ XmlTableSetDocument(TableFuncScanState *state, Datum value)
4695
4675
4696
4676
PG_TRY ();
4697
4677
{
4698
- doc = xmlCtxtReadMemory (xtCxt -> ctxt , (char * ) xstr , length , NULL , NULL , XML_PARSE_HUGE );
4678
+ doc = xmlCtxtReadMemory (xtCxt -> ctxt , (char * ) xstr , length , NULL , NULL , 0 );
4699
4679
if (doc == NULL || xtCxt -> xmlerrcxt -> err_occurred )
4700
4680
xml_ereport (xtCxt -> xmlerrcxt , ERROR , ERRCODE_INVALID_XML_DOCUMENT ,
4701
4681
"could not parse XML document" );
0 commit comments