FasterXML / woodstox

The gold standard Stax XML API implementation. Now at Github.
Apache License 2.0
220 stars 81 forks source link

support setting ReaderConfig on WstxInputFactory #168

Closed pjfanning closed 1 year ago

pjfanning commented 1 year ago

I ran into an issue in jackson-dataformat-xml. I tried to write a test with deeply nested XML. The ReaderConfig defaults kicked in - applying a depth limit of 1000. This is good.

I thought that I'd write a 2nd test where I raised the limit but I can't find a way of injecting a custom ReaderConfig and I thought that WstxInputFactory would be a good place to do this.

The existing test that shows the limit being applied is https://github.com/FasterXML/jackson-dataformat-xml/pull/576/files#diff-6d1868818258b6a8eb9d22b6032bf80797c30ab6f65e826faa7e9456cc1e16a4

pjfanning commented 1 year ago

I found this approach works:

    final WstxInputFactory wstxInputFactory = new WstxInputFactory();
    wstxInputFactory.getConfig().setMaxElementDepth(2000);
cowtowncoder commented 1 year ago

Yeah the only concern really is if tests used different Stax implementation: but these constraints are Woodstox-specific (and not Stax2 extension) so there isn't much we can do anyway.