Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pwagland opened this issue Jan 13, 2022 · 0 comments
Open

Comments

@pwagland
Copy link

Text stolen from FasterXML/woodstox#51

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 we'll probably need to add support.

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.

This issue was found in our project when we tried to comply with SonarQubes warning that we should always disable DTD resolution.

We have a method:

  public static javax.xml.stream.XMLInputFactory buildXMLInputFactory(NameSpace ns)
  {
    javax.xml.stream.XMLInputFactory factory = javax.xml.stream.XMLInputFactory.newInstance();
    factory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); // Compliant ← This is (XMLInputFactory.java:277)
    factory.setProperty(javax.xml.stream.XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
    factory.setProperty(javax.xml.stream.XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
    factory.setProperty(javax.xml.stream.XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.valueOf(ns == NameSpace.NAMESPACE_AWARE));
    return factory;
  }

And this fails with:

Caused by: java.lang.IllegalArgumentException: Unrecognized property 'http://javax.xml.XMLConstants/property/accessExternalDTD'
    at com.fasterxml.aalto.impl.CommonConfig.setProperty(CommonConfig.java:135)
    at com.fasterxml.aalto.in.ReaderConfig.setProperty(ReaderConfig.java:373)
    at com.fasterxml.aalto.stax.InputFactoryImpl.setProperty(InputFactoryImpl.java:229)
    at com.company.xml.XMLInputFactory.buildXMLInputFactory(XMLInputFactory.java:277)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant