Projects
openEuler:24.03:SP1:Everything
dom4j
_service:tar_scm:backport-Default-SAXParser-fea...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:backport-Default-SAXParser-features-are-set-when-SAXParser-is.patch of Package dom4j
From a16aaa7a192f5e5258dd941cb6a4344c1ca80839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Jirs=C3=A1k?= <filip@jirsak.org> Date: Sun, 1 Jul 2018 13:20:26 +0200 Subject: [PATCH] #44 Default SAXParser features are set when SAXParser is created, so they can be overriden. (cherry picked from commit 161078a8a520dcd1db6d451190f2434d56547664) --- src/main/java/org/dom4j/io/SAXHelper.java | 15 +++++++++++++++ src/main/java/org/dom4j/io/SAXReader.java | 23 +---------------------- src/test/java/org/dom4j/io/DTDTest.java | 2 ++ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/dom4j/io/SAXHelper.java b/src/main/java/org/dom4j/io/SAXHelper.java index 0810a90c..f120337f 100644 --- a/src/main/java/org/dom4j/io/SAXHelper.java +++ b/src/main/java/org/dom4j/io/SAXHelper.java @@ -103,6 +103,21 @@ public static XMLReader createXMLReader(boolean validating) throw new SAXException("Couldn't create SAX reader"); } + // configure namespace support + SAXHelper.setParserFeature(reader, "http://xml.org/sax/features/namespaces", true); + SAXHelper.setParserFeature(reader, "http://xml.org/sax/features/namespace-prefixes", false); + + // external entites +// SAXHelper.setParserFeature(reader, "http://xml.org/sax/properties/external-general-entities", false); +// SAXHelper.setParserFeature(reader, "http://xml.org/sax/properties/external-parameter-entities", false); + + // external DTD + SAXHelper.setParserFeature(reader,"http://apache.org/xml/features/nonvalidating/load-external-dtd", false); + + + // use Locator2 if possible + SAXHelper.setParserFeature(reader,"http://xml.org/sax/features/use-locator2", true); + return reader; } diff --git a/src/main/java/org/dom4j/io/SAXReader.java b/src/main/java/org/dom4j/io/SAXReader.java index 23559e49..6bb3d926 100644 --- a/src/main/java/org/dom4j/io/SAXReader.java +++ b/src/main/java/org/dom4j/io/SAXReader.java @@ -65,11 +65,7 @@ public class SAXReader { private static final String SAX_STRING_INTERNING = "http://xml.org/sax/features/string-interning"; - private static final String SAX_NAMESPACE_PREFIXES = - "http://xml.org/sax/features/namespace-prefixes"; - private static final String SAX_NAMESPACES = - "http://xml.org/sax/features/namespaces"; - private static final String SAX_DECL_HANDLER = + private static final String SAX_DECL_HANDLER = "http://xml.org/sax/properties/declaration-handler"; private static final String SAX_LEXICAL_HANDLER = "http://xml.org/sax/properties/lexical-handler"; @@ -902,27 +898,10 @@ protected void configureReader(XMLReader reader, DefaultHandler handler) SAXHelper.setParserProperty(reader, SAX_DECL_HANDLER, handler); } - // configure namespace support - SAXHelper.setParserFeature(reader, SAX_NAMESPACES, true); - - SAXHelper.setParserFeature(reader, SAX_NAMESPACE_PREFIXES, false); - // string interning SAXHelper.setParserFeature(reader, SAX_STRING_INTERNING, isStringInternEnabled()); - // external entites - /* - * SAXHelper.setParserFeature( reader, - * "http://xml.org/sax/properties/external-general-entities", - * includeExternalGeneralEntities ); SAXHelper.setParserFeature( reader, - * "http://xml.org/sax/properties/external-parameter-entities", - * includeExternalParameterEntities ); - */ - // use Locator2 if possible - SAXHelper.setParserFeature(reader, - "http://xml.org/sax/features/use-locator2", true); - try { // configure validation support reader.setFeature("http://xml.org/sax/features/validation", diff --git a/src/test/java/org/dom4j/io/DTDTest.java b/src/test/java/org/dom4j/io/DTDTest.java index ff77e4be..1c432328 100644 --- a/src/test/java/org/dom4j/io/DTDTest.java +++ b/src/test/java/org/dom4j/io/DTDTest.java @@ -445,6 +445,8 @@ protected Document readDocument(String resourceName, reader.setEntityResolver(new MyEntityResolver(DTD_FILE, DTD_PUBLICID, DTD_SYSTEM_ID)); + reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", true); + return getDocument(resourceName, reader); }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2