Author: Christian Hudon <chr...@pianocktail.org> Branch: stdlib-2.7.5 Changeset: r67170:4b9d6834816b Date: 2013-09-29 23:07 -0400 http://bitbucket.org/pypy/pypy/changeset/4b9d6834816b/
Log: Raise an error when finding a C0 control character in JSON string for pypyjson implementation. Fixes new, failing test in stdlib-2.7.5. diff --git a/pypy/module/_pypyjson/interp_decoder.py b/pypy/module/_pypyjson/interp_decoder.py --- a/pypy/module/_pypyjson/interp_decoder.py +++ b/pypy/module/_pypyjson/interp_decoder.py @@ -317,6 +317,8 @@ 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): diff --git a/pypy/module/_pypyjson/test/test__pypyjson.py b/pypy/module/_pypyjson/test/test__pypyjson.py --- a/pypy/module/_pypyjson/test/test__pypyjson.py +++ b/pypy/module/_pypyjson/test/test__pypyjson.py @@ -185,4 +185,8 @@ 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)") _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit