File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
camel-core/src/main/java/org/apache/camel/processor/validation Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ protected SchemaFactory createSchemaFactory() {
175
175
}
176
176
if (camelContext == null || !Boolean .parseBoolean (camelContext .getGlobalOptions ().get (ACCESS_EXTERNAL_DTD ))) {
177
177
try {
178
+ LOG .debug ("Configuring SchemaFactory to not allow access to external DTD/Schema" );
178
179
factory .setProperty (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
179
180
} catch (SAXException e ) {
180
181
LOG .warn (e .getMessage (), e );
Original file line number Diff line number Diff line change 22
22
import java .net .URL ;
23
23
import java .util .Collections ;
24
24
25
+ import javax .xml .XMLConstants ;
25
26
import javax .xml .parsers .ParserConfigurationException ;
26
27
import javax .xml .transform .Result ;
27
28
import javax .xml .transform .Source ;
53
54
import org .slf4j .Logger ;
54
55
import org .slf4j .LoggerFactory ;
55
56
57
+ import static org .apache .camel .processor .validation .SchemaReader .ACCESS_EXTERNAL_DTD ;
58
+
56
59
/**
57
60
* A processor which validates the XML version of the inbound message body
58
61
* against some schema either in XSD or RelaxNG
@@ -100,6 +103,16 @@ protected void doProcess(Exchange exchange) throws Exception {
100
103
}
101
104
102
105
Validator validator = schema .newValidator ();
106
+ // turn off access to external schema by default
107
+ if (!Boolean .parseBoolean (exchange .getContext ().getGlobalOptions ().get (ACCESS_EXTERNAL_DTD ))) {
108
+ try {
109
+ LOG .debug ("Configuring Validator to not allow access to external DTD/Schema" );
110
+ validator .setProperty (XMLConstants .ACCESS_EXTERNAL_DTD , "" );
111
+ validator .setProperty (XMLConstants .ACCESS_EXTERNAL_SCHEMA , "" );
112
+ } catch (SAXException e ) {
113
+ LOG .warn (e .getMessage (), e );
114
+ }
115
+ }
103
116
104
117
// the underlying input stream, which we need to close to avoid locking files or other resources
105
118
Source source = null ;
You can’t perform that action at this time.
0 commit comments