Skip to content

Commit

Permalink
chore: Remove xerces #1743
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Apr 22, 2024
1 parent f0d1f91 commit a652620
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
1 change: 0 additions & 1 deletion core/matchers/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies {
implementation 'javax.mail:mail:1.5.0-b01'
implementation 'org.apache.tika:tika-core'
implementation 'io.github.java-diff-utils:java-diff-utils:4.12'
implementation 'xerces:xercesImpl:2.12.2'
implementation 'org.atteo:evo-inflector:1.3'
implementation 'com.github.ajalt:mordant:1.2.1'
implementation 'com.github.zafarkhaja:java-semver:0.9.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import au.com.dius.pact.core.support.Result
import au.com.dius.pact.core.support.zipAll
import io.pact.plugins.jvm.core.InteractionContents
import io.github.oshai.kotlinlogging.KLogging
import org.apache.xerces.dom.TextImpl
import org.w3c.dom.NamedNodeMap
import org.w3c.dom.Node
import org.w3c.dom.Node.CDATA_SECTION_NODE
Expand Down Expand Up @@ -52,18 +51,18 @@ object XmlContentMatcher : ContentMatcher, KLogging() {
}

fun parse(xmlData: String): Node {
val dbFactory = DocumentBuilderFactory.newInstance()
if (System.getProperty("pact.matching.xml.validating") == "false") {
dbFactory.isValidating = false
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false)
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
}
if (System.getProperty("pact.matching.xml.namespace-aware") != "false") {
dbFactory.isNamespaceAware = true
}
return if (xmlData.isEmpty()) {
TextImpl()
dbFactory.newDocumentBuilder().newDocument()
} else {
val dbFactory = DocumentBuilderFactory.newInstance()
if (System.getProperty("pact.matching.xml.validating") == "false") {
dbFactory.isValidating = false
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false)
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false)
}
if (System.getProperty("pact.matching.xml.namespace-aware") != "false") {
dbFactory.isNamespaceAware = true
}
val dBuilder = dbFactory.newDocumentBuilder()
val xmlInput = InputSource(StringReader(xmlData))
val doc = dBuilder.parse(xmlInput)
Expand Down

0 comments on commit a652620

Please sign in to comment.