Skip to content

Commit 08e5fec

Browse files
authored
Merge pull request #542 from SethTisue/issue541
2 parents 272b573 + e826be8 commit 08e5fec

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

jvm/src/test/scala/scala/xml/parsing/ConstructingParserTest.scala

+13-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,22 @@ class ConstructingParserTest {
7575
@Test
7676
def SI6341issue65: Unit = {
7777
val str = """<elem one="test" two="test2" three="test3"/>"""
78-
val cpa = ConstructingParser.fromSource(io.Source.fromString(str), preserveWS = true)
78+
val cpa = ConstructingParser.fromSource(Source.fromString(str), preserveWS = true)
7979
val cpadoc = cpa.document()
8080
val ppr = new PrettyPrinter(80,5)
8181
val out = ppr.format(cpadoc.docElem)
8282
assertEquals(str, out)
8383
}
84+
85+
// https://github.com/scala/scala-xml/issues/541
86+
@Test
87+
def issue541: Unit = {
88+
val xml =
89+
"""|<script>// <![CDATA[
90+
|[]; // ]]>
91+
|</script>""".stripMargin
92+
val parser = ConstructingParser.fromSource(Source.fromString(xml), preserveWS = true)
93+
parser.document().docElem // shouldn't crash
94+
}
95+
8496
}

shared/src/main/scala/scala/xml/parsing/MarkupParser.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests {
5858
protected var curInput: Source = input
5959

6060
// See ticket #3720 for motivations.
61-
private class WithLookAhead(underlying: Source) extends Source {
61+
// As for why it's `private[parsing]` rather than merely `private`, see
62+
// https://github.com/scala/scala-xml/issues/541 ; the broader access is necessary,
63+
// for now anyway, to work around https://github.com/lampepfl/dotty/issues/13096
64+
private[parsing] class WithLookAhead(underlying: Source) extends Source {
6265
private val queue = scala.collection.mutable.Queue[Char]()
6366
def lookahead(): BufferedIterator[Char] = {
6467
val iter = queue.iterator ++ new Iterator[Char] {

0 commit comments

Comments
 (0)