-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Closed
Copy link
Description
Symfony version(s) affected: 5.0
Description
If you start an XMLEncode::encode process in the middle of a normalization (you need to create an base64 encoded XML sub document), cause an "Wrong Document Error" DomDocument exception at:
$parentNode->appendChild($node); |
Here is the call stack:
- The app call the serialize with: $serializer->serialize($data, "xml", [...context...]);
- The first serialize call the createDomDocument at:
$this->dom = $this->createDomDocument($context); - The XMLEncoder call normalizer at:
$data = $this->serializer->normalize($data, $this->format, $this->context); - In CustomNormalizer::normalize we call
$serializer->serialize($otherdata, "xml", [...other context...]); - Second serialize override dom at:
$this->dom = $this->createDomDocument($context); - When we done the normalization the encoder fails here because the second serializer did override the dom:
$parentNode->appendChild($node);
How to reproduce
Create an XML with an base64 encoded xml subcontent:
<?xml version="1.0"?>
<node>...base64encoded xml...</node>
xml to base64 encode:
<?xml version="1.0"?>
<node2>test</node2>
Possible Solution
DOMDocument of XMLEncoder should stackable.
Additional context
I will post repo, test and PR later.