Skip to content

Commit b536bf7

Browse files
committed
Add parameter to the decryptElement method to make optional the formatting
1 parent de7f72a commit b536bf7

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Saml2/Utils.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,13 @@ public static function getStatus(DOMDocument $dom)
10981098
*
10991099
* @param DOMElement $encryptedData The encrypted data.
11001100
* @param XMLSecurityKey $inputKey The decryption key.
1101+
* @param bool $formatOutput Format or not the output.
11011102
*
11021103
* @return DOMElement The decrypted element.
11031104
*
11041105
* @throws Exception
11051106
*/
1106-
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey)
1107+
public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey $inputKey, $formatOutput = true)
11071108
{
11081109

11091110
$enc = new XMLSecEnc();
@@ -1188,8 +1189,10 @@ public static function decryptElement(DOMElement $encryptedData, XMLSecurityKey
11881189

11891190
$xml = '<root xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$decrypted.'</root>';
11901191
$newDoc = new DOMDocument();
1191-
$newDoc->preserveWhiteSpace = false;
1192-
$newDoc->formatOutput = true;
1192+
if ($formatOutput) {
1193+
$newDoc->preserveWhiteSpace = false;
1194+
$newDoc->formatOutput = true;
1195+
}
11931196
$newDoc = self::loadXML($newDoc, $xml);
11941197
if (!$newDoc) {
11951198
throw new ValidationError(

0 commit comments

Comments
 (0)