You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
XML parser: refactor hardening to XMLSecurity class, and make sure parser used in JAXBSerialiser on a SAXSource is hardened if not using MOXy (which sets up its own hardened parser, and varies behaviour if called with raw source vs a parsed source)
thrownewRuntimeException("Malformed XML from " + file);
@@ -451,7 +531,9 @@ public Object deserialise(final InputSource source)
451
531
452
532
try
453
533
{
454
-
finalObjectobj = unmarshaller.unmarshal(source);
534
+
// MOXy disables DTDs and external entities by default when it owns the parse, so wrapping its input in a parser we build ourselves is unnecessary (MOXy also applies stricter type coercion on a {@link SAXSource} with an external reader)
535
+
// A StreamSource carries raw, unparsed XML; other Source types are already parsed or carry their own reader.
thrownewRuntimeException("Malformed XML! JAXB returned null");
@@ -474,7 +556,24 @@ public Object deserialise(final Source source)
474
556
475
557
try
476
558
{
477
-
finalObjectobj = unmarshaller.unmarshal(source);
559
+
// MOXy disables DTDs and external entities by default when it owns the parse, so wrapping its input in a parser we build ourselves is unnecessary (MOXy also applies stricter type coercion on a {@link SAXSource} with an external reader)
560
+
// A StreamSource carries raw, unparsed XML; other Source types are already parsed or carry their own reader.
561
+
finalSourceeffectiveSource;
562
+
if (!isMOXY && sourceinstanceofjavax.xml.transform.stream.StreamSourcestream)
0 commit comments