From ffa90f8d9e97b591b8a7ce5f5ba2829731f3091f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no>
Date: Fri, 16 Oct 2009 12:45:30 +0000
Subject: [PATCH] Fix two fixes that caused SimpleSAMLphp in some cases to
 produce schema-invalid metadata

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1864 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/Metadata/SAMLBuilder.php | 2 +-
 lib/SimpleSAML/Metadata/SAMLParser.php  | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php
index 87702af25..a8f26191e 100644
--- a/lib/SimpleSAML/Metadata/SAMLBuilder.php
+++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php
@@ -287,7 +287,7 @@ class SimpleSAML_Metadata_SAMLBuilder {
 		}
 
 
-		if ( array_key_exists('name', $metadata) || array_key_exists('attributes', $metadata)) {
+		if ( array_key_exists('name', $metadata) && array_key_exists('attributes', $metadata)) {
 			/**
 			 * Add an AttributeConsumingService element with information as name and description and list
 			 * of requested attributes
diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php
index 80f88b9a7..73510ae24 100644
--- a/lib/SimpleSAML/Metadata/SAMLParser.php
+++ b/lib/SimpleSAML/Metadata/SAMLParser.php
@@ -481,6 +481,7 @@ class SimpleSAML_Metadata_SAMLParser {
 		if($acs === NULL) {
 			SimpleSAML_Logger::warning('Could not find a supported SAML 1.x AssertionConsumerService endpoint for ' .
 				var_export($ret['entityid'], TRUE) . '.');
+			return;
 		} else {
 			$ret['AssertionConsumerService'] = $acs['Location'];
 		}
@@ -506,7 +507,6 @@ class SimpleSAML_Metadata_SAMLParser {
 			break;
 		}
 
-
 		return $ret;
 	}
 
@@ -548,6 +548,7 @@ class SimpleSAML_Metadata_SAMLParser {
 		if($sso === NULL) {
 			SimpleSAML_Logger::warning('Could not find a supported SAML 1.x SingleSignOnService endpoint for ' .
 				var_export($ret['entityid'], TRUE) . '.');
+			return;
 		} else {
 			$ret['SingleSignOnService'] = $sso['Location'];
 		}
@@ -877,8 +878,7 @@ class SimpleSAML_Metadata_SAMLParser {
 		$attcs = SimpleSAML_Utilities::getDOMChildren($element, 'AttributeConsumingService', '@md');
 		if (count($attcs) > 0) {
 			self::parseAttributeConsumerService($attcs[0], $sp);
-		}
-		
+		}	
 
 		$this->spDescriptors[] = $sp;
 	}
-- 
GitLab