Is Scala/Java not respecting w3 “excess dtd traffic” specs?

后端 未结 9 1173
青春惊慌失措
青春惊慌失措 2021-02-01 07:40

I\'m new to Scala, so I may be off base on this, I want to know if the problem is my code. Given the Scala file httpparse, simplified to:

object Http {
   import         


        
9条回答
  •  礼貌的吻别
    2021-02-01 08:35

    This is a scala problem. Native Java has an option to disable loading the DTD:

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

    There are no equivalent in scala.

    If you somewhat want to fix it yourself, check scala/xml/parsing/FactoryAdapter.scala and put the line in

    278   def loadXML(source: InputSource): Node = {
    279     // create parser
    280     val parser: SAXParser = try {
    281       val f = SAXParserFactory.newInstance()
    282       f.setNamespaceAware(false)
    

    <-- insert here

    283       f.newSAXParser()
    284     } catch {
    285       case e: Exception =>
    286         Console.err.println("error: Unable to instantiate parser")
    287         throw e
    288     }
    

提交回复
热议问题