File tree Expand file tree Collapse file tree
src/test/java/org/apache/xml/security/test/dom/parser Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2222import org .apache .xml .security .utils .XMLUtils ;
2323import org .junit .jupiter .api .Test ;
2424import org .w3c .dom .Document ;
25+ import org .xml .sax .SAXParseException ;
2526
2627import java .io .ByteArrayInputStream ;
2728import java .nio .charset .StandardCharsets ;
@@ -153,10 +154,15 @@ void testDeeplyNestedElements() {
153154 try {
154155 XMLUtils .read (bais , false );
155156 } catch (XMLParserException e ) {
156- // Stack overflow protection is acceptable
157- assertTrue (e .getMessage ().contains ("depth" ) ||
158- e .getMessage ().contains ("stack" ) ||
159- e .getMessage ().contains ("nested" ),
157+ /*
158+ * Stack overflow protection is acceptable - in this case there will be a parent
159+ * SAXParseException with a specific text.
160+ */
161+ assertTrue (e .getCause () instanceof SAXParseException );
162+ SAXParseException saxEx = (SAXParseException ) e .getCause ();
163+ assertTrue (saxEx .getMessage ().contains ("depth" ) ||
164+ saxEx .getMessage ().contains ("stack" ) ||
165+ saxEx .getMessage ().contains ("nested" ),
160166 "Deep nesting should trigger protection" );
161167 }
162168 }, "Parser should handle deep nesting gracefully" );
You can’t perform that action at this time.
0 commit comments