mbien commented on code in PR #173:
URL: https://github.com/apache/roller/pull/173#discussion_r3941265135


##########
app/src/main/java/org/apache/roller/weblogger/util/SafeSAXBuilder.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional
+ * information regarding copyright in this work, please see the NOTICE
+ * file in the top level directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.util;
+
+import javax.xml.XMLConstants;
+
+import org.jdom2.input.SAXBuilder;
+import org.jdom2.input.sax.XMLReaders;
+
+/**
+ * A {@link SAXBuilder} that treats a document strictly as data.
+ *
+ * <p>An XML document can name resources for the parser to go and read: a
+ * document type declaration can point at an external subset, and entity
+ * declarations can point at files or URLs. Resolving those makes the parser 
act
+ * on behalf of whoever wrote the document, which is only appropriate when the
+ * document is Roller's own.
+ *
+ * <p>Roller parses documents from user input and from its own menu, theme and
+ * configuration descriptors alike. Rather than track which parser is on which
+ * side, every retained JDOM parser is built here, and none of them resolve
+ * anything. Roller's own descriptors carry no document type declaration, so 
the
+ * strict setting costs them nothing.
+ *
+ * <p>The settings overlap deliberately. Refusing the declaration outright is
+ * what does the work; the remaining ones close the same door at the layers
+ * beneath, so a parser configured elsewhere, or a JAXP implementation with
+ * different defaults, does not quietly reopen it.
+ */
+public class SafeSAXBuilder extends SAXBuilder {

Review Comment:
   interesting that Roller doesn't have `DocumentBuilderFactory` anywhere. It 
was brand new in 2002 :)



-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to