From f78f8f66841dee698134367265d5067e4cfeccfe Mon Sep 17 00:00:00 2001 From: "Aaron S. Hawley" Date: Thu, 22 Feb 2018 12:15:13 -0500 Subject: [PATCH] Add billion laughs attack to test suite --- .../scala/xml/BillionLaughsAttackTest.scala | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 jvm/src/test/scala/scala/xml/BillionLaughsAttackTest.scala 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 + +}