Skip to content

Commit 25bf192

Browse files
lrytzadriaanm
authored andcommitted
Fix 4138
1 parent 529b3b6 commit 25bf192

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/library/scala/util/parsing/combinator/JavaTokenParsers.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package scala.util.parsing.combinator
1111

12+
import annotation.migration
13+
1214
/** `JavaTokenParsers` differs from [[scala.util.parsing.combinator.RegexParsers]]
1315
* by adding the following definitions:
1416
*
@@ -39,12 +41,13 @@ trait JavaTokenParsers extends RegexParsers {
3941
/** Double quotes (`"`) enclosing a sequence of:
4042
*
4143
* - Any character except double quotes, control characters or backslash (`\`)
42-
* - A backslash followed by a slash, another backslash, or one of the letters
43-
* `b`, `f`, `n`, `r` or `t`.
44+
* - A backslash followed by another backslash, a single or double quote, or one
45+
* of the letters `b`, `f`, `n`, `r` or `t`
4446
* - `\` followed by `u` followed by four hexadecimal digits
4547
*/
48+
@migration("`stringLiteral` allows escaping single and double quotes, but not forward slashes any longer.", "2.10.0")
4649
def stringLiteral: Parser[String] =
47-
("\""+"""([^"\p{Cntrl}\\]|\\[\\/bfnrt]|\\u[a-fA-F0-9]{4})*"""+"\"").r
50+
("\""+"""([^"\p{Cntrl}\\]|\\[\\'"bfnrt]|\\u[a-fA-F0-9]{4})*"""+"\"").r
4851
/** A number following the rules of `decimalNumber`, with the following
4952
* optional additions:
5053
*

test/files/run/t4138.check

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[1.45] parsed: "lir 'de\' ' \\ \n / upa \"new\" \t parsing"
2+
[1.5] parsed: "s "

test/files/run/t4138.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test extends App {
2+
object p extends scala.util.parsing.combinator.JavaTokenParsers
3+
4+
println(p.parse(p.stringLiteral, """"lir 'de\' ' \\ \n / upa \"new\" \t parsing""""))
5+
println(p.parse(p.stringLiteral, """"s " lkjse""""))
6+
}

0 commit comments

Comments
 (0)