Skip to content

Commit 457c341

Browse files
[DEL] fn:doc: options dropped. qt#2223
1 parent 619747a commit 457c341

File tree

7 files changed

+6
-40
lines changed

7 files changed

+6
-40
lines changed

basex-core/src/main/java/org/basex/core/CommonOptions.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,8 @@ public interface CommonOptions {
1616
/** XSD validation option value. */
1717
String STRICT = "strict";
1818

19-
/** Internal option: {@link MainOptions#EXTERNALENT}. */
20-
BooleanOption ALLOW_EXTERNAL_ENTITIES = new BooleanOption("allow-external-entities", true);
2119
/** Internal option: {@link MainOptions#DTDVALIDATION}. */
2220
BooleanOption DTD_VALIDATION = new BooleanOption("dtd-validation", false);
23-
/** Internal option: {@link MainOptions#ENTEXPANSION}. */
24-
NumberOption ENTITY_EXPANSION_LIMIT = new NumberOption("entity-expansion-limit", -1);
2521
/** Internal option: {@link MainOptions#STRIPNS}. */
2622
BooleanOption STRIP_SPACE = new BooleanOption("strip-space", false);
2723
/** Internal option: {@link MainOptions#XINCLUDE}. */

basex-core/src/main/java/org/basex/core/MainOptions.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ public final class MainOptions extends Options {
6161
public static final BooleanOption STRIPWS = new BooleanOption("STRIPWS", false);
6262
/** Strip namespaces. */
6363
public static final BooleanOption STRIPNS = new BooleanOption("STRIPNS", false);
64-
/** Whether external entities are permitted or rejected. */
65-
public static final BooleanOption EXTERNALENT = new BooleanOption("EXTENTITIES", true);
66-
/** Limit on the maximum number of entity references that may be expanded. */
67-
public static final NumberOption ENTEXPANSION = new NumberOption("ENTEXPANSION", -1);
6864
/** Flag for parsing DTDs. */
6965
public static final BooleanOption DTD = new BooleanOption("DTD", false);
7066
/** Flag for DTD validation. */
@@ -204,8 +200,6 @@ public final class MainOptions extends Options {
204200
XMLPARSINGMAP.put(CommonOptions.INTPARSE, INTPARSE);
205201
XMLPARSINGMAP.put(CommonOptions.STRIP_SPACE, STRIPWS);
206202
XMLPARSINGMAP.put(CommonOptions.STRIPNS, STRIPNS);
207-
XMLPARSINGMAP.put(CommonOptions.ALLOW_EXTERNAL_ENTITIES, EXTERNALENT);
208-
XMLPARSINGMAP.put(CommonOptions.ENTITY_EXPANSION_LIMIT, ENTEXPANSION);
209203
XMLPARSINGMAP.put(CommonOptions.DTD, DTD);
210204
XMLPARSINGMAP.put(CommonOptions.DTD_VALIDATION, DTDVALIDATION);
211205
XMLPARSINGMAP.put(CommonOptions.XSD_VALIDATION, XSDVALIDATION);

basex-core/src/main/java/org/basex/io/parse/xml/XmlParser.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,17 @@ public void parse(final InputStream stream) throws IOException, SAXException {
6060
public static XMLReader reader(final MainOptions options)
6161
throws SAXException, ParserConfigurationException {
6262

63-
final int entExpansion = options.get(MainOptions.ENTEXPANSION);
64-
final boolean extEntities = options.get(MainOptions.EXTERNALENT);
6563
final boolean dtd = options.get(MainOptions.DTD);
6664
final boolean dtdValidation = options.get(MainOptions.DTDVALIDATION);
6765
final boolean xinclude = options.get(MainOptions.XINCLUDE);
6866
final boolean xsdValidation = CommonOptions.STRICT.equals(
6967
options.get(MainOptions.XSDVALIDATION));
7068
final boolean xsiLocation = options.get(MainOptions.XSILOCATION);
7169
final SAXParserFactory f = SAXParserFactory.newDefaultInstance();
72-
if(extEntities) {
73-
// setting these options to false will ignore external entities, rather than rejecting them
74-
f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", dtd);
75-
f.setFeature("http://xml.org/sax/features/external-general-entities", dtd);
76-
f.setFeature("http://xml.org/sax/features/external-parameter-entities", dtd);
77-
}
70+
// setting these options to false will ignore external entities, rather than rejecting them
71+
f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", dtd);
72+
f.setFeature("http://xml.org/sax/features/external-general-entities", dtd);
73+
f.setFeature("http://xml.org/sax/features/external-parameter-entities", dtd);
7874
f.setFeature("http://xml.org/sax/features/validation", dtdValidation);
7975
f.setFeature("http://xml.org/sax/features/use-entity-resolver2", false);
8076
f.setNamespaceAware(true);
@@ -86,9 +82,7 @@ public static XMLReader reader(final MainOptions options)
8682
f.setSchema(sf.newSchema());
8783
}
8884
final XMLReader xr = f.newSAXParser().getXMLReader();
89-
if(entExpansion != -1) xr.setProperty(
90-
"http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit", entExpansion);
91-
if(xsdValidation && !xsiLocation || !extEntities) {
85+
if(xsdValidation && !xsiLocation) {
9286
xr.setEntityResolver((pubId, sysId) -> {
9387
throw new SAXException("External access not allowed: " + sysId);
9488
});

basex-core/src/main/java/org/basex/query/func/fn/DocOptions.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
public final class DocOptions extends Options {
1717
/** DTD validation. */
1818
public static final BooleanOption DTD_VALIDATION = CommonOptions.DTD_VALIDATION;
19-
/** Whether external entities are permitted or rejected. */
20-
public static final BooleanOption ALLOW_EXTERNAL_ENTITIES = CommonOptions.ALLOW_EXTERNAL_ENTITIES;
21-
/** Limit on the maximum number of entity references that may be expanded. */
22-
public static final NumberOption ENTITY_EXPANSION_LIMIT = CommonOptions.ENTITY_EXPANSION_LIMIT;
2319
/** Remove whitespace-only text nodes. */
2420
public static final BooleanOption STRIP_SPACE = CommonOptions.STRIP_SPACE;
2521
/** Flag for using XInclude. */

basex-core/src/main/java/org/basex/query/func/fn/Docs.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,7 @@ void check(final Options options, final boolean fragment, final QueryContext qc)
9292
final Predicate<BooleanOption> bool = o -> options.get(o) == Boolean.TRUE;
9393
final boolean dtd = bool.test(CommonOptions.DTD) || bool.test(MainOptions.DTD);
9494
final boolean xinclude = bool.test(CommonOptions.XINCLUDE) || bool.test(MainOptions.XINCLUDE);
95-
final boolean externalent = bool.test(CommonOptions.ALLOW_EXTERNAL_ENTITIES) ||
96-
bool.test(MainOptions.EXTERNALENT);
97-
if(dtd || xinclude || externalent) checkPerm(qc, Perm.CREATE);
95+
if(dtd || xinclude) checkPerm(qc, Perm.CREATE);
9896

9997
final boolean intparse = fragment || bool.test(CommonOptions.INTPARSE) ||
10098
bool.test(MainOptions.INTPARSE);

basex-core/src/main/java/org/basex/query/func/fn/FnParseXml.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ public final class FnParseXml extends FnParseXmlFragment {
1717
public static final class ParseXmlOptions extends ParseXmlFragmentOptions {
1818
/** DTD validation. */
1919
public static final BooleanOption DTD_VALIDATION = CommonOptions.DTD_VALIDATION;
20-
/** Whether external entities are permitted. */
21-
public static final BooleanOption ALLOW_EXTERNAL_ENTITIES =
22-
CommonOptions.ALLOW_EXTERNAL_ENTITIES;
23-
/** Limit on the maximum number of entity references that may be expanded. */
24-
public static final NumberOption ENTITY_EXPANSION_LIMIT = CommonOptions.ENTITY_EXPANSION_LIMIT;
2520
/** Whether any xi:include elements in the input are to be processed. */
2621
public static final BooleanOption XINCLUDE = CommonOptions.XINCLUDE;
2722
/** XSD validation. */

basex-core/src/test/java/org/basex/core/CatalogTest.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.basex.core;
22

3-
import static org.basex.query.QueryError.*;
43
import static org.basex.query.func.Function.*;
54

65
import org.basex.*;
@@ -107,8 +106,6 @@ public final class CatalogTest extends SandboxTest {
107106
set(MainOptions.CATALOG, CATALOG);
108107
query(func.args("http://doc.xml", " { 'dtd': true() }"), "<doc>X</doc>");
109108
query(func.args("http://doc.xml", " { 'dtd': false() }"), "<doc/>");
110-
query(func.args("http://doc.xml", " { 'allow-external-entities': true() }"), "<doc>X</doc>");
111-
error(func.args("http://doc.xml", " { 'allow-external-entities': false() }"), IOERR_X);
112109
}
113110

114111
/** Test method.*/
@@ -120,9 +117,5 @@ public final class CatalogTest extends SandboxTest {
120117
" { 'dtd': true() }"), "<doc>X</doc>");
121118
query(func.args("<!DOCTYPE xml SYSTEM 'http://dtd.dtd'><doc>&amp;x;</doc>",
122119
" { 'dtd': 'no' }"), "<doc/>");
123-
query(func.args("<!DOCTYPE xml SYSTEM 'http://dtd.dtd'><doc>&amp;x;</doc>",
124-
" { 'allow-external-entities': true() }"), "<doc>X</doc>");
125-
error(func.args("<!DOCTYPE xml SYSTEM 'http://dtd.dtd'><doc>&amp;x;</doc>",
126-
" { 'allow-external-entities': 'no' }"), SAXERR_X);
127120
}
128121
}

0 commit comments

Comments
 (0)