You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/12/15 00:39:03 UTC

[GitHub] [hadoop] slfan1989 commented on a diff in pull request #5224: HADOOP-18575: make transformer factory more lenient

slfan1989 commented on code in PR #5224:
URL: https://github.com/apache/hadoop/pull/5224#discussion_r1049104213


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/XMLUtils.java:
##########
@@ -156,8 +156,18 @@ public static SAXTransformerFactory newSecureSAXTransformerFactory()
           throws TransformerConfigurationException {
     SAXTransformerFactory trfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
     trfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-    trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-    trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+    quietSet(trfactory, XMLConstants.ACCESS_EXTERNAL_DTD, "");
+    quietSet(trfactory, XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
     return trfactory;
   }
+
+  private static boolean quietSet(TransformerFactory transformerFactory, String name, Object value) {
+    try {
+      transformerFactory.setAttribute(name, value);
+      return true;
+    } catch (Exception|Error e) {
+      // ok to ignore

Review Comment:
   Can we record some logs?



-- 
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: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org