Skip to content

Commit 9908250

Browse files
committed
Merge pull request #1 from ashawley/fix-35-out-of-memory
Fix 35 out of memory
2 parents 5fb415a + 578072f commit 9908250

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/main/scala/scala/xml/parsing/MarkupParserCommon.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
6363
*/
6464
def xAttributeValue(endCh: Char): String = {
6565
val buf = new StringBuilder
66-
while (ch != endCh) {
66+
while (ch != endCh && !eof) {
6767
// well-formedness constraint
6868
if (ch == '<') return errorAndResult("'<' not allowed in attrib value", "")
6969
else if (ch == SU) truncatedError("")

src/test/scala/scala/xml/XMLTest.scala

+6
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,12 @@ expected closing tag of foo
838838
assertEquals("""<x:foo xmlns:x="gaga"/>""", pp.format(x))
839839
}
840840

841+
@UnitTest( expected = classOf[scala.xml.SAXParseException] )
842+
def issue35: Unit = {
843+
val broken = "<broken attribute='is truncated"
844+
XML.loadString(broken)
845+
}
846+
841847
@UnitTest
842848
def nodeSeqNs: Unit = {
843849
val x = {

src/test/scala/scala/xml/pull/XMLEventReaderTest.scala

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package scala.xml.pull
1+
package scala.xml
2+
package pull
23

34
import org.junit.Test
45
import org.junit.Ignore
@@ -40,6 +41,17 @@ class XMLEventReaderTest {
4041
er.stop // allow thread to be garbage-collected
4142
}
4243

44+
@Test
45+
def issue35: Unit = {
46+
val broken = "<broken attribute='is truncated"
47+
val x = new Source {
48+
val iter = broken.iterator
49+
override def reportError(pos: Int, msg: String, out: java.io.PrintStream = Console.err) {}
50+
}
51+
val r = new XMLEventReader(x)
52+
assertTrue(r.next.isInstanceOf[EvElemStart])
53+
}
54+
4355
@Test(expected = classOf[Exception])
4456
def missingTagTest: Unit = {
4557
val data=

0 commit comments

Comments
 (0)