mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-01-14 15:53:53 +01:00
17 lines
540 B
Scala
17 lines
540 B
Scala
package com.ysoft.odc
|
|
|
|
import javax.xml.parsers.SAXParserFactory
|
|
|
|
import scala.xml.{Elem, XML}
|
|
|
|
// copied from https://github.com/scala/scala-xml/issues/17 and slightly modified
|
|
|
|
object SecureXml {
|
|
def loadString(xml: String): Elem = {
|
|
val spf = SAXParserFactory.newInstance()
|
|
spf.setFeature("http://xml.org/sax/features/external-general-entities", false)
|
|
spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)
|
|
val saxParser = spf.newSAXParser()
|
|
XML.withSAXParser(saxParser).loadString(xml)
|
|
}
|
|
} |