Skip to content

Commit 5e9c726

Browse files
authored
Merge commit from fork
1 parent f6f32a3 commit 5e9c726

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

1112
use function count;
@@ -67,7 +68,12 @@ public static function canonicalizeData(
6768
}
6869
}
6970

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

7379

0 commit comments

Comments
 (0)