|
7 | 7 | use DOMElement; |
8 | 8 | use SimpleSAML\XMLSecurity\Constants as C; |
9 | 9 | use SimpleSAML\XMLSecurity\Exception\CanonicalizationFailedException; |
| 10 | +use SimpleSAML\XMLSecurity\Exception\ReferenceValidationFailedException; |
| 11 | +use SimpleSAML\XMLSecurity\Utils\XPath; |
10 | 12 | use SimpleSAML\XMLSecurity\XML\ds\Transforms; |
11 | 13 | use SimpleSAML\XPath\Constants as XPATH_C; |
12 | 14 |
|
@@ -140,15 +142,22 @@ public function processTransforms( |
140 | 142 | $arXPath = []; |
141 | 143 | $xpathValue = $xpath->getContent()->getValue(); |
142 | 144 | $arXPath['query'] = '(.//. | .//@* | .//namespace::*)[' . $xpathValue . ']'; |
143 | | - |
144 | | -// $arXpath['namespaces'] = $xpath->getNamespaces(); |
145 | | - // TODO: review if $nsnode->localName is equivalent to the keys in getNamespaces() |
146 | | -// $nslist = $xp->query('./namespace::*', $node); |
147 | | -// foreach ($nslist as $nsnode) { |
148 | | -// if ($nsnode->localName != "xml") { |
149 | | -// $arXPath['namespaces'][$nsnode->localName] = $nsnode->nodeValue; |
150 | | -// } |
151 | | -// } |
| 145 | + $arXpath['namespaces'] = $xpath->getNamespaces(); |
| 146 | + |
| 147 | + $xpCache = XPath::getXPath($data); |
| 148 | + $nslist = $xpCache->query('./namespace::*', $xpath->toXML()); |
| 149 | + Assert::lessThanEq( |
| 150 | + $nslist->count(), |
| 151 | + C::MAX_XPATH_NAMESPACES, |
| 152 | + ReferenceValidationFailedException::class, |
| 153 | + 'Too many namespaces.', |
| 154 | + ); |
| 155 | + |
| 156 | + foreach ($nslist as $nsnode) { |
| 157 | + if ($nsnode->localName != "xml") { |
| 158 | + $arXPath['namespaces'][$nsnode->localName] = $nsnode->nodeValue; |
| 159 | + } |
| 160 | + } |
152 | 161 | } |
153 | 162 | break; |
154 | 163 | } |
|
0 commit comments