stevedlawrence commented on a change in pull request #560:
URL: https://github.com/apache/daffodil/pull/560#discussion_r638136275



##########
File path: 
daffodil-japi/src/main/java/org/apache/daffodil/japi/package-info.java
##########
@@ -257,7 +257,7 @@
  *  WritableByteChannel wbc = java.nio.channels.Channels.newChannel(os);
  *  DaffodilUnparseContentHandler unparseContentHandler = 
dp.newContentHandlerInstance(wbc);
  *  try {
- *   XMLReader xmlReader = 
SAXParserFactory.newInstance().newSAXParser().getXMLReader();
+ *   XMLReader xmlReader = SAXParserFactory().newSAXParser().getXMLReader;

Review comment:
       Don't you need the SAXParserFactory.newInstance() in Java? I don't think 
you can just do SAXParserFactory()?

##########
File path: 
daffodil-lib/src/main/scala/org/apache/daffodil/xml/DaffodilSAXParserFactory.scala
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.daffodil.xml
+
+import org.apache.xerces.jaxp.SAXParserFactoryImpl
+
+
+class DaffodilSAXParserFactory private ()
+  extends SAXParserFactoryImpl() {
+
+  override def newSAXParser() = {
+    val res = super.newSAXParser()
+    XMLUtils.setSecureDefaults(res.getXMLReader)

Review comment:
       Does this make it so all future calls to getXMLReader will have secure 
defaults set? I assumed that getXMLReader would allocate a new instance 
everytime it's call, and so would need setSecureDefaults set on it?

##########
File path: 
daffodil-tdml-processor/src/main/scala/org/apache/daffodil/tdml/processor/DaffodilTDMLDFDLProcessor.scala
##########
@@ -350,7 +350,7 @@ class DaffodilTDMLDFDLProcessor private (private var dp: 
DataProcessor) extends
     val saxOutputChannel = 
java.nio.channels.Channels.newChannel(saxOutputStream)
     val unparseContentHandler = dp.newContentHandlerInstance(saxOutputChannel)
     unparseContentHandler.enableInputterResolutionOfRelativeInfosetBlobURIs()
-    val xmlReader = SAXParserFactory.newInstance.newSAXParser.getXMLReader
+    val xmlReader = DaffodilSAXParserFactory().newSAXParser.getXMLReader

Review comment:
       This is still calling setSecureDfeaults below. Is that still needed?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to