Skip to content

Commit ab7fff7

Browse files
committed
Add parameter to the decryptElement method to make optional the formatting
1 parent 428ffa8 commit ab7fff7

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lib/Saml2/Utils.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,13 @@ public static function getStatus($dom)
11001100
*
11011101
* @param DOMElement $encryptedData The encrypted data.
11021102
* @param XMLSecurityKey $inputKey The decryption key.
1103+
* @param bool $formatOutput Format or not the output.
11031104
*
11041105
* @return DOMElement The decrypted element.
11051106
*
11061107
* @throws Exception
11071108
*/
1108-
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey)
1109+
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey, $formatOutput = true)
11091110
{
11101111

11111112
$enc = new XMLSecEnc();
@@ -1190,8 +1191,10 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
11901191

11911192
$xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$decrypted.'</root>';
11921193
$newDoc = new DOMDocument();
1193-
$newDoc->preserveWhiteSpace = false;
1194-
$newDoc->formatOutput = true;
1194+
if ($formatOutput) {
1195+
$newDoc->preserveWhiteSpace = false;
1196+
$newDoc->formatOutput = true;
1197+
}
11951198
$newDoc = self::loadXML($newDoc, $xml);
11961199
if (!$newDoc) {
11971200
throw new OneLogin_Saml2_ValidationError(
@@ -1211,7 +1214,7 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
12111214
return $decryptedElement;
12121215
}
12131216

1214-
/**
1217+
/**
12151218
* Converts a XMLSecurityKey to the correct algorithm.
12161219
*
12171220
* @param XMLSecurityKey $key The key.

0 commit comments

Comments
 (0)