Skip to content

Commit

Permalink
fixed two bugs: potential stack overflow and also treat DEL correctly…
Browse files Browse the repository at this point in the history
…. (thanks robey and john k!)
  • Loading branch information
stevejwriter committed Jun 27, 2009
1 parent b1c0b82 commit 6f9bec3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/scala/com/twitter/commons/Json.scala
Expand Up @@ -31,7 +31,7 @@ private class JsonParser extends JavaTokenParsers {
}

def string: Parser[String] =
"\"" ~> """([^\"\p{Cntrl}\\]|\\[\\/bfnrt"]|\\u[a-fA-F0-9]{4})*""".r <~ "\"" ^^
"\"" ~> """([^\"[\x00-\x1F]\\]+|\\[\\/bfnrt"]|\\u[a-fA-F0-9]{4})*""".r <~ "\"" ^^
{ _.replace("""\/""", "/").unquoteC }

def value: Parser[Any] = obj | arr | string | number |
Expand Down
5 changes: 5 additions & 0 deletions src/test/scala/com/twitter/commons/JsonSpec.scala
Expand Up @@ -39,6 +39,11 @@ object JsonSpec extends Specification {
Json.parse("""["x\"x"]""") mustEqual
List("x\"x")
}

"accept unquoted DEL char, as isn't considered control char in Json spec" in {
//Json.parse("""["A^?B"]""") mustEqual List("A^?B")
Json.parse("[\"A\u007fB\"]") mustEqual List("A\u007fB")
}
}

"parse maps" in {
Expand Down

0 comments on commit 6f9bec3

Please sign in to comment.