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

Issue with supporting XML requests which sends a DTD in the latest scala-xml version #237

Open
danielbeddoe123 opened this issue Nov 17, 2022 · 0 comments

Comments

@danielbeddoe123
Copy link

danielbeddoe123 commented Nov 17, 2022

The SAX parser created in scala-xml 2.1.0 has the following feature set to true by default:

parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)

This has the consequence that when using this library and our client code sends an XML request with a DTD in it, MatchIr. fromXmlString which is used by BodyMatching.matchBodies fails to parse the XML properly and we end up with body match failures.

We would like some way of supplying a custom parser or supplying some configuration to toggle that feature, for e.g:

private val XML: XMLLoader[Elem] = createXMLParser(disallowDocType = false)
def createXMLParser(disallowDocType: Boolean = true): XMLLoader[Elem] = {
    val sAXParserFactory = SAXParserFactory.newInstance()
    sAXParserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", disallowDocType);
    val saxParser = sAXParserFactory.newSAXParser()
    xml.XML.withSAXParser(saxParser)
}

What are your thoughts about this feature request? I can try to have a go at at getting this done myself and raise a PR but wanted to run this by you first as per your contributing guidelines state.

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