99use SimpleSAML \XML \Assert \Assert ;
1010use SimpleSAML \XML \Attribute ;
1111use SimpleSAML \XML \Constants as C ;
12+ use SimpleSAML \XMLSchema \Exception \InvalidDOMAttributeException ;
13+ use SimpleSAML \XMLSchema \Exception \SchemaViolationException ;
1214use SimpleSAML \XMLSchema \Type \StringValue ;
1315use SimpleSAML \XMLSchema \XML \Constants \NS ;
1416
@@ -204,7 +206,7 @@ function (Attribute $attr) {
204206
205207 if ($ namespace === NS ::LOCAL ) {
206208 // If ##local then all namespaces must be null
207- Assert::allNull ($ actual_namespaces );
209+ Assert::allNull ($ actual_namespaces, SchemaviolationException::class );
208210 } elseif (is_array ($ namespace )) {
209211 // Make a local copy of the property that we can edit
210212 $ allowed_namespaces = $ namespace ;
@@ -227,25 +229,28 @@ function (Attribute $attr) {
227229 rtrim (implode (', ' , $ diff )),
228230 self ::NS ,
229231 ),
232+ SchemaViolationException::class,
230233 );
231234 } else {
232235 if ($ namespace === NS ::OTHER ) {
233236 // All attributes must be namespaced, ergo non-null
234- Assert::allNotNull ($ actual_namespaces );
237+ Assert::allNotNull ($ actual_namespaces, SchemaViolationException::class );
235238
236239 // Must be any namespace other than the parent element
237- Assert::allNotSame ($ actual_namespaces , self ::NS );
240+ Assert::allNotSame ($ actual_namespaces , self ::NS , SchemaViolationException::class );
238241 } elseif ($ namespace === NS ::TARGETNAMESPACE ) {
239242 // Must be the same namespace as the one of the parent element
240- Assert::allSame ($ actual_namespaces , self ::NS );
243+ Assert::allSame ($ actual_namespaces , self ::NS , SchemaViolationException::class );
241244 }
242245 }
243246
244247 $ exclusionList = self ::getAttributeExclusions ();
245248 foreach ($ attributes as $ i => $ attr ) {
246- if (in_array ([$ attr ->getNamespaceURI (), $ attr ->getAttrName ()], $ exclusionList , true )) {
247- unset($ attributes [$ i ]);
248- }
249+ Assert::true (
250+ !in_array ([$ attr ->getNamespaceURI (), $ attr ->getAttrName ()], $ exclusionList , true )
251+ && !in_array ([$ attr ->getNamespaceURI (), '* ' ], $ exclusionList , true ),
252+ InvalidDOMAttributeException::class,
253+ );
249254 }
250255
251256 $ this ->namespacedAttributes = $ attributes ;
0 commit comments