Commits

Christian Hudon  committed 4b9d683

Raise an error when finding a C0 control character in JSON string for pypyjson implementation. Fixes new, failing test in stdlib-2.7.5.

  • Participants
  • Parent commits ba85bb6
  • Branches stdlib-2.7.5

Comments (0)

Files changed (2)

File pypy/module/_pypyjson/interp_decoder.py

                 return self.decode_string_escaped(start, content_so_far)
             elif ch == '\0':
                 self._raise("Unterminated string starting at char %d", start)
+            elif ch < '\x20' or ch == '\x7f':
+                self._raise("Invalid control character at char %d", self.pos-1)
 
 
     def decode_string_escaped(self, start, content_so_far):

File pypy/module/_pypyjson/test/test__pypyjson.py

         res = _pypyjson.loads('"z\\ud834\\udd20x"')
         assert res == expected
 
-
+    def test_tab_in_string_should_fail(self):
+        import _pypyjson
+        # http://json.org/JSON_checker/test/fail25.json
+        s = '["\ttab\tcharacter\tin\tstring\t"]'
+        raises(ValueError, "_pypyjson.loads(s)")