FasterXML/woodstox

Add support for JEP-185 (JAXP-1.5) properties named `ACCESS_EXTERNAL_`

Opened this issue · 4 comments

Apparently there's a JEP to add Yet Another Set of configuration properties (to overlap with existing) ones:

http://openjdk.java.net/jeps/185

and since users will be trying to use them (as per #50) we'll probably need to add support.
(no one from JEP-185 has tried to reach the project prior to this user request)

It is further unfortunate these are added as System properties since that has all the problems of global variables; as well as the question of how these should interact with existing configuration settings.
But it is what it is and this is becoming Oracle's walled garden so. shrug.

veita commented

The system properties are useful for risk mitigation in legacy applications and third party depencencies where it is often impossible to configure internally used parsers programmatically.

@veita yes, true enough. Security aspects may be one area where it is one of lesser evils.
I guess the fundamental root cause realistically is that Stax spec did not specify default for "javax.xml.stream.isReplacingEntityReferences" to be false. But that's difficult to rectify at this point.

Note to self: ACCESS_ properties have been added in XMLConstants in Java 7. Given that Woodstox requires only Java 6, this could be problematic if we rely on constants. Except that, I think final static constants may be folded in during compilation... need to verify, but if so, we have to compile on Java 7 (1.7), but Java 6 runtime should still be ok.

Also: to make sure, JEP part relevant reads:

JAXP 1.5 adds three new API-level properties to limit external connections to specific, named protocols:

javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD: A list of protocols by which external DTDs and external entity references may be accessed.

javax.xml.XMLConstants.ACCESS_EXTERNAL_SCHEMA: A list of protocols via which external schema references, specified by the schemaLocation attribute of import and include elements, may be resolved.

javax.xml.XMLConstants.ACCESS_EXTERNAL_STYLESHEET: A list of protocols via which external references specified in stylesheet constructs such as processing instructions, document() functions, import elements, and include elements may be resolved.

It also adds three corresponding system properties, to provide developers the ability to change the settings without changing code:

javax.xml.accessExternalDTD for ACCESS_EXTERNAL_DTD

javax.xml.accessExternalSchema for ACCESS_EXTERNAL_SCHEMA

javax.xml.accessExternalStylesheet for ACCESS_EXTERNAL_STYLESHEET

Finally, it allows the above properties to be set in the existing configuration file, ${java.home}/lib/jaxp.properties, so as to define the behavior for all invocations of the JDK or JRE. The format of entries in the file is property-name=value, for example:

javax.xml.accessExternalDTD=file,http

and specifically ignores FEATURE_SECURE_PROCESSING, for which I will create separate issue.