[
https://issues.apache.org/jira/browse/NIFI-4062?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16127469#comment-16127469
]
ASF GitHub Bot commented on NIFI-4062:
--------------------------------------
Github user arunma commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2080#discussion_r133234584
--- Diff:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateXPath.java
---
@@ -219,6 +239,25 @@ public void onTrigger(final ProcessContext context,
final ProcessSession session
}
final ComponentLog logger = getLogger();
+ final DocumentBuilderFactory
docBuilderFactory=docBuilderFactoryRef.get();
+ final DocumentBuilder docBuilder;
+ try {
+ docBuilder = docBuilderFactory.newDocumentBuilder();
+
+ if (!context.getProperty(VALIDATE_DTD).asBoolean()) {
+ docBuilder.setEntityResolver(new EntityResolver() {
+ @Override
+ public InputSource resolveEntity(String publicId,
String systemId) throws SAXException, IOException {
+ return new InputSource(new StringReader(""));
+ }
+ });
+ }
+ } catch (ParserConfigurationException e) {
+ logger.error("Configuration error while constructing
DocumentBuilder {}", new Object[]{e});
+ session.transfer(flowFiles, REL_FAILURE);
+ return;
--- End diff --
@ijokarumawak Brilliant. That makes a lot of sense and I understand the
spirit of it. Also, with the new change, there is a place where I am
instantiating the XMLReader and that throws a SAX Exception. I feel that there
is no way to recover from it and have transferred the flow to FAILURE. Let me
know if that ought to be changed.
> Provide an option to disable DTD validation for EvaluateXPath and
> EvaluateXQuery
> --------------------------------------------------------------------------------
>
> Key: NIFI-4062
> URL: https://issues.apache.org/jira/browse/NIFI-4062
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Extensions
> Affects Versions: 1.0.0
> Reporter: Koji Kawamura
> Assignee: Arun Manivannan
> Labels: beginner
>
> Currently EvaluateXPath and EvaluateXQuery can fail if the source document
> has DOCTYPE definition in it, especially using external DTD. It would be
> useful if these processor provides a property to disable DTD validation when
> evaluate XPath or XQuery.
> References:
> https://community.hortonworks.com/questions/107121/does-evaluatexpath-support-doctype.html
> https://stackoverflow.com/questions/243728/how-to-disable-dtd-at-runtime-in-javas-xpath
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)