Skip to content

Commit c1b310c

Browse files
authored
Merge commit from fork
1 parent a3c18cf commit c1b310c

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace SimpleSAML\XMLSecurity\Exception;
6+
7+
/**
8+
* Class CanonicalizationFailedException
9+
*
10+
* This exception is thrown when we can't canonicalize the referenced document.
11+
*
12+
* @package simplesamlphp/xml-security
13+
*/
14+
class CanonicalizationFailedException extends RuntimeException
15+
{
16+
/**
17+
* @param string $message
18+
*/
19+
public function __construct(string $message = 'Canonicalization failed.')
20+
{
21+
parent::__construct($message);
22+
}
23+
}

src/Utils/XML.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use DOMElement;
88
use SimpleSAML\XMLSecurity\Constants as C;
9+
use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException;
910
use SimpleSAML\XMLSecurity\XML\ds\Transforms;
1011
use SimpleSAML\XPath\Constants as XPATH_C;
1112

@@ -68,7 +69,12 @@ public static function canonicalizeData(
6869
}
6970
}
7071

71-
return $element->C14N($exclusive, $withComments, $xpaths, $prefixes);
72+
$ret = $element->C14N($exclusive, $withComments, $xpaths, $prefixes);
73+
if ($ret === false) {
74+
// GHSA-h25p-2wxc-6584
75+
throw new CanonicalizationFailedException();
76+
}
77+
return $ret;
7278
}
7379

7480

0 commit comments

Comments
 (0)