File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
jvm/src/test/scala/scala/xml Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ package scala .xml
2+
3+ import org .junit .Test
4+
5+ class BillionLaughsAttackTest {
6+
7+ /**
8+ * org.xml.sax.SAXParseException: JAXP00010001: The parser has
9+ * encountered more than "64000" entity expansions in this document;
10+ * this is the limit imposed by the JDK.
11+ */
12+ @ Test (expected= classOf [org.xml.sax.SAXParseException ])
13+ def lolzTest : Unit = {
14+ XML .loadString(lolz)
15+ }
16+
17+ // Copied from https://msdn.microsoft.com/en-us/magazine/ee335713.aspx
18+ val lolz =
19+ """ <?xml version="1.0"?>
20+ |<!DOCTYPE lolz [
21+ | <!ENTITY lol "lol">
22+ | <!ELEMENT lolz (#PCDATA)>
23+ | <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
24+ | <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
25+ | <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
26+ | <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
27+ | <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
28+ | <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
29+ | <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
30+ | <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
31+ | <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
32+ |]>
33+ |<lolz>&lol9;</lolz>
34+ |""" .stripMargin
35+
36+ }
You can’t perform that action at this time.
0 commit comments