Skip to content

Commit

Permalink
Merge pull request #1747 from pact-foundation/chore/remove-xerces
Browse files Browse the repository at this point in the history
chore: Remove xerces #1743
  • Loading branch information
rholshausen authored Dec 11, 2023
2 parents 0f015b2 + ece6a68 commit b3c2bcb
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 @@ -17,7 +17,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 b3c2bcb

Please sign in to comment.