mirror of
https://github.com/ysoftdevs/odc-analyzer.git
synced 2026-03-30 05:51:59 +02:00
Initial commit
This commit is contained in:
17
app/com/ysoft/odc/SecureXml.scala
Normal file
17
app/com/ysoft/odc/SecureXml.scala
Normal file
@@ -0,0 +1,17 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user