From 3d774897fddc11d95dd57886e811cdf34fbe1fcf Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 17 Aug 2009 11:27:09 +0000
Subject: [PATCH] saml2_Message: Support DOMNodeList as attribute values.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1684 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/saml2/lib/Message.php | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/modules/saml2/lib/Message.php b/modules/saml2/lib/Message.php
index 369006286..866d95f32 100644
--- a/modules/saml2/lib/Message.php
+++ b/modules/saml2/lib/Message.php
@@ -472,12 +472,15 @@ class sspmod_saml2_Message {
 					$value = (string)$value;
 					break;
 				case 'base64':
-					$value = base64_encode($value);
+					$value = base64_encode((string)$value);
 					break;
 				case 'raw':
-					$doc = new DOMDocument();
-					$doc->loadXML('<root>' . $value . '</root>');
-					$value = $doc->firstChild->childNodes;
+					if (is_string($value)) {
+						$doc = new DOMDocument();
+						$doc->loadXML('<root>' . $value . '</root>');
+						$value = $doc->firstChild->childNodes;
+					}
+					assert('$value instanceof DOMNodeList');
 					break;
 				default:
 					throw new SimpleSAML_Error_Exception('Invalid encoding for attribute ' .
-- 
GitLab