Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 5, 2023
2 parents ec2a59e + f5cc10a commit 26685c4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package tools.jackson.dataformat.xml.dos;

import com.ctc.wstx.stax.WstxInputFactory;

import tools.jackson.core.JsonParser;
import tools.jackson.core.exc.StreamReadException;
import tools.jackson.dataformat.xml.XmlFactory;
import tools.jackson.dataformat.xml.XmlMapper;
import tools.jackson.dataformat.xml.XmlTestBase;

Expand All @@ -22,20 +19,6 @@ public void testDeepDoc() throws Exception
}
}

public void testDeepDocWithCustomDepthLimit() throws Exception
{
final WstxInputFactory wstxInputFactory = new WstxInputFactory();
wstxInputFactory.getConfig().setMaxElementDepth(2000);
XmlMapper xmlMapper = new XmlMapper(
XmlFactory.builder()
.xmlInputFactory(wstxInputFactory)
.build());
final String XML = createDeepNestedDoc(1050);
try (JsonParser p = xmlMapper.createParser(XML)) {
while (p.nextToken() != null) { }
}
}

private String createDeepNestedDoc(final int depth) {
StringBuilder sb = new StringBuilder();
sb.append("<root>");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package tools.jackson.dataformat.xml.woodstox;

import com.ctc.wstx.stax.WstxInputFactory;

import tools.jackson.core.JsonParser;

import tools.jackson.dataformat.xml.XmlFactory;
import tools.jackson.dataformat.xml.XmlMapper;
import tools.jackson.dataformat.xml.XmlTestBase;

public class DeepNestingWoodstoxParserTest extends XmlTestBase
{
// Try using Woodstox-specific settings above and beyond
// what Jackson-core would provide
public void testDeepDocWithWoodstoxLimits() throws Exception
{
final WstxInputFactory wstxInputFactory = new WstxInputFactory();
wstxInputFactory.getConfig().setMaxElementDepth(2000);
XmlMapper xmlMapper = new XmlMapper(
XmlFactory.builder()
.xmlInputFactory(wstxInputFactory)
.build());
final String XML = createDeepNestedDoc(1050);
try (JsonParser p = xmlMapper.createParser(XML)) {
while (p.nextToken() != null) { }
}
}

private String createDeepNestedDoc(final int depth) {
StringBuilder sb = new StringBuilder();
sb.append("<root>");
for (int i = 0; i < depth; i++) {
sb.append("<leaf>");
}
sb.append("abc");
for (int i = 0; i < depth; i++) {
sb.append("</leaf>");
}
sb.append("</root>");
return sb.toString();
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package tools.jackson.dataformat.xml.deser;
package tools.jackson.dataformat.xml.woodstox;

import java.util.List;

import javax.xml.stream.XMLInputFactory;

import com.ctc.wstx.stax.WstxInputFactory;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import tools.jackson.dataformat.xml.XmlFactory;
Expand All @@ -14,7 +12,9 @@
import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty;

// [dataformat-xml#422]
// [dataformat-xml#422]: while setting itself is NOT Woodstox-specific,
// many/most Stax implementations do not offer non-namespace-aware mode
// so let's separate this into Woodstox-specific section
public class NonNamespaceAwareDeser422Test extends XmlTestBase
{
// [dataformat-xml#422]
Expand Down Expand Up @@ -55,7 +55,7 @@ static class RssItem {

public void testBigDocIssue422() throws Exception
{
final XMLInputFactory xmlInputFactory = new WstxInputFactory();
final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, false);
final XmlMapper xmlMapper = XmlMapper.builder(XmlFactory.builder()
.xmlInputFactory(xmlInputFactory)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Package that contains <a href="https://github.com/FasterXML/woodstox/">Woodstox</a>
* - specific tests, distinct from general Stax-backed tests.
*
* @since 2.17
*/
package tools.jackson.dataformat.xml.woodstox;

0 comments on commit 26685c4

Please sign in to comment.