You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by GitBox <gi...@apache.org> on 2022/09/05 16:46:52 UTC
[GitHub] [calcite] rubenada commented on a diff in pull request #2892: [CALCITE-5263] Improve XmlFunctions by using an XML DocumentBuilder
rubenada commented on code in PR #2892:
URL: https://github.com/apache/calcite/pull/2892#discussion_r963051068
##########
core/src/test/java/org/apache/calcite/test/SqlXmlFunctionsTest.java:
##########
@@ -36,6 +36,18 @@
*/
class SqlXmlFunctionsTest {
+ private static final String XML = "<document>string</document>";
+ private static final String FILE = System.getProperty("os.name").startsWith("Windows")
+ ? "file:///C:/Windows/System32/drivers/etc/hosts"
+ : "file:///etc/hosts";
Review Comment:
Switched to temp file
##########
core/src/main/java/org/apache/calcite/runtime/XmlFunctions.java:
##########
@@ -215,6 +238,27 @@ private static String convertNodeToString(Node node) throws TransformerException
return writer.toString();
}
+ private static Node getDocumentNode(final String xml) {
+ final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setXIncludeAware(false);
+ documentBuilderFactory.setExpandEntityReferences(false);
+ documentBuilderFactory.setNamespaceAware(true);
+ try {
+ documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ documentBuilderFactory
+ .setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ } catch (final ParserConfigurationException e) {
+ throw new IllegalArgumentException("Document Builder configuration failed", e);
Review Comment:
Changed into IllegalStateException
--
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: commits-unsubscribe@calcite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org