Skip to content

Instantly share code, notes, and snippets.

@stof
Created October 25, 2013 16:55
Show Gist options
  • Save stof/7157964 to your computer and use it in GitHub Desktop.
Save stof/7157964 to your computer and use it in GitHub Desktop.
Fix for the error handler of the Symfony Xml decoding
diff --git a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
index 137f2fc..dbc0a27 100644
--- a/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
+++ b/src/Symfony/Component/Serializer/Encoder/XmlEncoder.php
@@ -76,6 +76,10 @@ class XmlEncoder extends SerializerAwareEncoder implements EncoderInterface, Dec
libxml_use_internal_errors($internalErrors);
libxml_disable_entity_loader($disableEntities);
+ if ($error = libxml_get_last_error()) {
+ throw new UnexpectedValueException($error->message);
+ }
+
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
throw new UnexpectedValueException('Document types are not allowed.');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment