Skip to content
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

DOMDocument::loadXML(): CData section too big found #86

Closed
sreekeshkamath opened this issue Aug 30, 2024 · 4 comments
Closed

DOMDocument::loadXML(): CData section too big found #86

sreekeshkamath opened this issue Aug 30, 2024 · 4 comments
Labels
Bug Something isn't working

Comments

@sreekeshkamath
Copy link

sreekeshkamath commented Aug 30, 2024

Bug Report

Q A
Version(s) 2.22.0

Summary

If data of more than 10 MB is passed to setContent() with <![CDATA[{$content}]]>, we get CData section too big error.

Please note that CDATA is still not being passed to the setContent() as mentioned here.

Current behavior

Error is being thrown and execution stops at loadXML() located in Writer/Renderer/Entry/Atom.php.

How to reproduce

The following is in PHP:

While creating the feed, simply call the below function insidesetContent()

private function getCdataFromContent(?string $content = ''): string
    {
        $content = str_repeat('This is a large text. ', 1000000); // Creates a large string over 10MB
        return "<![CDATA[{$content}]]>";
    }

Expected behavior

XML should be generated for files larger than 10MB.

@sreekeshkamath sreekeshkamath added the Bug Something isn't working label Aug 30, 2024
@froschdesign
Copy link
Member

The XML_PARSE_HUGE flag as option for DOMDocument::loadXML can help here, but this could lead to problems on the consumer side, because it is not certain if a parser can process the huge file.
What do you put in a feed that is this big?

@sreekeshkamath
Copy link
Author

sreekeshkamath commented Sep 1, 2024

It's basically a feed produced by the client who's content exceeds 10 million characters, which is why we need to have XML_PARSH_HUGE flag for loadXML(). Can it be put as an optional argument in the package?

@froschdesign
Copy link
Member

Can it be put as an optional argument in the package?

No, because a size of 10 MB for a feed does not correspond to a regular usage and possible problems on the consumer side.

But you can extend the relevant classes for your use case:

if ($entry instanceof Writer\Entry) {
$renderer = new Renderer\Entry\Atom($entry);
} else {

Then render the feed with your custom feed and entry classes:

$renderer = new MyCustom\Feed\Atom($feed);
$renderer->setType('atom');
$xml = $renderer->render()->saveXml();

@sreekeshkamath
Copy link
Author

sreekeshkamath commented Sep 3, 2024

Oh ok, thought it might have been a bug. Then the only solution would be to extend the class. Thanks anyways!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants