Permalink
Browse files

Colon not allowed inside an array

  • Loading branch information...
1 parent 863f207 commit fe833d8fab2a1f27b67e131299cf13430a7867e5 Joni Freeman committed Jun 15, 2011
@@ -303,6 +303,7 @@ object JsonParser {
}
fail("expected null")
case ':' =>
+ if (blocks.peek == ARRAY) fail("Colon in an invalid position")
fieldNameMode = false
case '[' =>
blocks.addFirst(ARRAY)
@@ -21,7 +21,6 @@ import util.control.Exception._
import org.specs.Specification
-
object ParserBugs extends Specification {
"Unicode ffff is a valid char in string literal" in {
parseOpt(""" {"x":"\uffff"} """).isDefined mustEqual true
@@ -31,4 +30,12 @@ object ParserBugs extends Specification {
allCatch.opt(parse(""" [ 2.2250738585072012e-308 ] """)) mustEqual None
allCatch.opt(parse(""" [ 22.250738585072012e-309 ] """)) mustEqual None
}
+
+ "Does not allow colon at start of array" in {
+ parseOpt("""[:"foo", "bar"]""") mustEqual None
+ }
+
+ "Does not allow colon instead of comma in array" in {
+ parseOpt("""["foo" : "bar"]""") mustEqual None
+ }
}

0 comments on commit fe833d8

Please sign in to comment.