From 226f65e7d22f1278a8eb60042cee305a6b9b0e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Fri, 21 Jan 2011 14:10:58 +0000 Subject: [PATCH] Fix for handling empty set of entityattributes. element without children git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2722 44740490-163a-0410-bde0-09ae8108e29a --- lib/SAML2/XML/mdattr/EntityAttributes.php | 6 ++++-- lib/SimpleSAML/Metadata/SAMLParser.php | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/SAML2/XML/mdattr/EntityAttributes.php b/lib/SAML2/XML/mdattr/EntityAttributes.php index a53056917..93590081c 100644 --- a/lib/SAML2/XML/mdattr/EntityAttributes.php +++ b/lib/SAML2/XML/mdattr/EntityAttributes.php @@ -60,8 +60,10 @@ class SAML2_XML_mdattr_EntityAttributes { $e = $doc->createElementNS(SAML2_XML_mdattr_EntityAttributes::NS, 'mdattr:EntityAttributes'); $parent->appendChild($e); - foreach ($this->children as $child) { - $child->toXML($e); + if (!empty($this->children)) { + foreach ($this->children as $child) { + $child->toXML($e); + } } return $e; diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index e81732999..02bfa5676 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -886,7 +886,7 @@ class SimpleSAML_Metadata_SAMLParser { // and not at RoleDescriptor level if ($element instanceof SAML2_XML_md_EntityDescriptor) { - if ($e instanceof SAML2_XML_mdattr_EntityAttributes) { + if ($e instanceof SAML2_XML_mdattr_EntityAttributes && !empty($e->children)) { foreach($e->children AS $attr) { -- GitLab