diff --git a/jvm/src/test/scala/scala/xml/BillionLaughsAttackTest.scala b/jvm/src/test/scala/scala/xml/BillionLaughsAttackTest.scala new file mode 100644 index 000000000..88e1e99b2 --- /dev/null +++ b/jvm/src/test/scala/scala/xml/BillionLaughsAttackTest.scala @@ -0,0 +1,36 @@ +package scala.xml + +import org.junit.Test + +class BillionLaughsAttackTest { + + /** + * org.xml.sax.SAXParseException: JAXP00010001: The parser has + * encountered more than "64000" entity expansions in this document; + * this is the limit imposed by the JDK. + */ + @Test(expected=classOf[org.xml.sax.SAXParseException]) + def lolzTest: Unit = { + XML.loadString(lolz) + } + + // Copied from https://msdn.microsoft.com/en-us/magazine/ee335713.aspx + val lolz = + """ + | + | + | + | + | + | + | + | + | + | + | + |]> + |&lol9; + |""".stripMargin + +}