Skip to content

Allow larger xml entity #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: copy_of_master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/backend/utils/adt/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,7 +1426,18 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace,
xml_ereport(xmlerrcxt, ERROR, ERRCODE_OUT_OF_MEMORY,
"could not allocate parser context");

if (xmloption_arg == XMLOPTION_DOCUMENT)
/*
* allow large XML entity values.
*
* Note that the latter code path doesn't preserve
* the ctxt->options value; so force the first code
* path. Yes, this breaks empty documents.
*
*
*/
ctxt->options |= XML_PARSE_HUGE;

if (true || (xmloption_arg == XMLOPTION_DOCUMENT))
{
/*
* Note, that here we try to apply DTD defaults
Expand Down Expand Up @@ -1463,6 +1474,15 @@ xml_parse(text *data, XmlOptionType xmloption_arg, bool preserve_whitespace,
doc->encoding = xmlStrdup((const xmlChar *) "UTF-8");
doc->standalone = standalone;

/*
* Attempt to allow large XML entity values.
*
* Hmm..... the docs imply this would work, but the parseFlag
* does not get copied to the xmlParserCtxtPtr created
* within xmlParseBalancedChunkMemory. :(
*/
doc->parseFlags = XML_PARSE_HUGE;

/* allow empty content */
if (*(utf8string + count))
{
Expand Down