Skip to content

Fix decoding of XML documents larger than 10 MB - #303

Open
railakhmadullin wants to merge 2 commits into
CoreOffice:mainfrom
railakhmadullin:fix-large-file-issue
Open

railakhmadullin wants to merge 2 commits into
CoreOffice:mainfrom
railakhmadullin:fix-large-file-issue

Conversation

@railakhmadullin

Copy link
Copy Markdown

Decoding a document larger than 10 MB fails on Linux with NSXMLParserErrorDomain error 1.

XMLStackParser creates the parser with XMLParser(data:). In that mode FoundationXML passes the whole document to libxml2's push parser as a single chunk. libxml2 rejects input over 10 MB unless XML_PARSE_HUGE is set, and XMLParser has no way to set it.

This PR switches to XMLParser(stream: InputStream(data: data)). The stream is read in 128 KB chunks, so no chunk reaches the limit.

Related to #251.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant