Jean Boussier
d0020d58f4
[ruby/json] Fix duplicated key warning location
...
Followup: https://github.com/ruby/json/pull/818
Now the warning should point at the `JSON.parse` caller, and not
inside the json gem itself.
cd51557387
2025-07-28 09:39:12 +09:00
Jean Boussier
b4ef5da70b
[ruby/json] Improve duplicate key warning and errors to include the key name
...
Followup: https://github.com/ruby/json/pull/818
e3de4cc59c
2025-07-28 09:39:11 +09:00
Scott Myron
50b6cd409a
Optimize 'json_parse_string' using SIMD.
2025-06-30 12:56:50 +09:00
Jean Boussier
93fc29c65c
[ruby/json] Deprecate duplicate keys in object
...
There are few legitimate use cases for duplicate keys, and can
in some case be exploited.
Rather to always silently accept them, we should emit a warning,
and in the future require to explictly allow them.
06f00a42e8
2025-06-24 12:10:50 +09:00
Jean Boussier
cd7495a1d0
[ruby/json] Further improve parsing errors
...
Report EOF when applicable instead of an empty fragment.
Also stop fragment extraction on first whitespace.
cc1daba860
2025-05-13 14:12:22 +09:00
Jean Boussier
50ef208369
[ruby/json] parser.c: include line and column in error messages
...
30e35b9ba5
2025-05-13 14:12:22 +09:00
Jean Boussier
1d07deb422
[ruby/json] Raise a ParserError on all incomplete unicode escape sequence.
...
This was the behavior until `2.10.0` unadvertently changed it.
`"\u1"` would raise, but `"\u1zzz"` wouldn't.
7d0637b9e6
2025-03-12 18:02:09 +09:00
Jean Boussier
0d62037fc0
[ruby/json] Ensure parser error snippets are valid UTF-8
...
Fix: https://github.com/ruby/json/issues/755
Error messages now include a snippet of the document
that doesn't parse to help locate the issue, however
the way it was done wasn't UTF-8 aware, and it could
result in exception messages with truncated characters.
It would be nice to go a bit farther and actually support
codepoints, but it's a lot of complexity to do it in C,
perhaps if we move that logic to Ruby given it's not a
performance sensitive codepath.
e144793b72
2025-02-27 13:32:32 +09:00
tompng
86b262179d
[ruby/json] Reject invalid number: -
-.1
-e0
...
b9bfeecfa9
2025-01-20 14:20:55 +01:00
tompng
525d7a68e4
[ruby/json] Raise parse error on invalid comments
...
2f57f40467
2025-01-20 14:20:55 +01:00
tompng
c026e44bb5
[ruby/json] Fix parsing incomplete unicode escape "\uaaa"
...
86c0d4eb7e
2025-01-20 14:20:55 +01:00
Jean Boussier
33708f2dc4
[ruby/json] Fix a regression in the parser with leading /
...
Ref: https://github.com/ruby/ruby/pull/12598
This could lead to an infinite loop.
f8cfa2696a
2025-01-20 10:31:56 +01:00
Jean Boussier
ef585744c0
Finalize Kevin's handrolled parser.
...
And get rid of the Ragel parser.
This is 7% faster on activitypub, 15% after on twitter and 11% faster
on citm_catalog.
There might be some more optimization opportunities, I did a quick
optimization pass to fix a regression in string parsing, but other
than that I haven't dug much in performance.
2025-01-20 16:09:00 +09:00
Jean Boussier
633f65e471
[ruby/json] Strip whitespaces
...
e85107197b
2024-11-05 18:00:36 +01:00
Jean Boussier
ca8f21ace8
[ruby/json] Resync
2024-11-05 18:00:36 +01:00
Benoit Daloze
e8522f06b5
[ruby/json] Re-enable passing test
...
82d21f01c5
2024-11-05 18:00:36 +01:00
Benoit Daloze
88b411464d
[ruby/json] Skip test failing on JRuby
...
0f0b16b3f5
2024-11-01 13:04:24 +09:00
Benoit Daloze
eb19156a28
[ruby/json] Add test for parsing broken strings
...
850bd077c4
2024-11-01 13:04:24 +09:00
Jean Boussier
b1d417dc7b
[ruby/json] Cleaner .encode / .force_encoding
...
cecf04fdfc
2024-10-26 18:44:15 +09:00
Jean Boussier
1045b9f820
[ruby/json] Modernize heredocs
...
fb25e94aea
2024-10-26 18:44:15 +09:00
Jean Boussier
70f554efb4
[ruby/json] raise_parse_error: avoid UB
...
Fix: https://github.com/ruby/json/pull/625
Declaring the buffer in a sub block cause bugs on some compilers.
90967c9eb0
2024-10-26 18:44:15 +09:00
Étienne Barrié
44aef5e852
[ruby/json] Drop compatibility for missing Array#permutation (Ruby <= 1.8.6)
...
b02091ed44
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Étienne Barrié
82f7550f65
Use frozen string literals
...
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Étienne Barrié
11348c583f
Use Encoding constants, String#b
...
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-10-26 18:44:15 +09:00
Jean Boussier
9045258c88
[ruby/json] Limit the size of ParserError exception messages
...
Fix: https://github.com/ruby/json/issues/534
Only include up to 32 bytes of unparseable the source.
f44995cfb6
2024-10-26 18:44:15 +09:00
Stephen Humphries
326a21d441
Relax Pure::Parser's comment regex...
...
...to allow any character sequence, including "/*", before then end
sequence of a multi-line ANSI C-style comment
.
2024-10-18 11:31:42 +09:00
Jean Boussier
8feed977a0
[ruby/json] Assume Encoding is defined
...
8713aa4812
2024-10-18 11:30:55 +09:00
Takumasa Ochi
20dc1e5c25
[ruby/json] Always dup argument to preserve original encoding for force_encoding
...
db9a489ca2
2024-10-18 11:30:42 +09:00
Jean Boussier
8c7e291dd8
Update references to flori/json
...
Now that the repository was transfered, these links will become
dead in a few months.
2024-10-07 20:12:57 -04:00
Hiroshi SHIBATA
7c8f9603b1
[flori/json] Make OpenStruct support as optional
...
202ffe2335
2024-01-31 14:56:00 +09:00
Hiroshi SHIBATA
b17ae88894
[flori/json] skip TruffleRuby
...
bab704eb49
2023-10-11 15:45:17 +09:00
Takashi Kokubun
96a809f621
Use require_relative in JSON tests
...
to prevent them from conflicting with yarp/test_helper
2023-08-25 15:32:14 -07:00
Hiroshi SHIBATA
56c8dab468
[flori/json] Skip BigDecimal tests when it's missing to load
...
3dd36c6077
2023-07-18 12:25:55 +09:00
Ethan
b2cc74a50d
[flori/json] test parsing of unicode, mixing literal characters with escaped
...
82fe866da2
2022-07-29 19:10:10 +09:00
Andrew Bromwich
a15d0e267a
[flori/json] Fix parser bug for empty string allocation
...
When `HAVE_RB_ENC_INTERNED_STR` is enabled it is possible to
pass through a null pointer to `rb_enc_interned_str` resulting
in a segfault
Fixes #495
b59368a8c2
2022-05-20 17:49:13 +09:00
Yusuke Endoh
762be87759
test/json/json_parser_test.rb: suppress warnings
...
20201021
T123003Z.log.html.gz
```
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:227: warning: ambiguous first argument; put parentheses or a space even after `-' operator
/home/chkbuild/chkbuild/tmp/build/20201021T123003Z/ruby/test/json/json_parser_test.rb:228: warning: ambiguous first argument; put parentheses or a space even after `-' operator
```
2020-10-21 23:37:42 +09:00
Nobuyoshi Nakada
d915e7ee00
strip trailing spaces [ci skip]
2020-10-20 23:52:19 +09:00
Jean Boussier
520e0916af
Implement a freeze: parser option
...
If set to true all parsed objects will be
immediately frozen, and strings will be
deduplicated if the Ruby implementation
allows it.
2020-10-20 21:40:25 +09:00
Jean Boussier
e1659af372
Add an option to escape forward slash character
...
Squashed commit of the following:
commit 26d181059989279a79c433cedcd893b4f52e42ee
Author: Francois Chagnon <francois.chagnon@jadedpixel.com>
Date: Tue Sep 15 21:17:34 2015 +0000
add config options for escape_slash
commit fa282334051b16df91ca097dd7304b46f3bc7719
Author: Francois Chagnon <francois.chagnon@jadedpixel.com>
Date: Mon Feb 9 21:09:33 2015 +0000
add forward slash to escape character
2020-09-25 17:28:42 +09:00
Hiroshi SHIBATA
3c77ef9adc
Ignore warnings about ambiguous first argument with the negative integer.
2019-06-01 15:07:35 +03:00
mrkn
a7e3516ff1
Fix JSON::Parser against bigdecimal updates
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-02 05:21:57 +00:00
ko1
ab8e756de0
require 'bigdecimal'
...
* test/json/json_parser_test.rb: this test needs bigdecimal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16 04:04:53 +00:00
hsbt
b304078ae6
Merge json-2.1.0 from https://github.com/flori/json
...
https://github.com/flori/json/blob/master/CHANGES.md#2017-04-18-210
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-16 03:04:46 +00:00
hsbt
11a94f2a36
* ext/json/*, test/json/json_parser_test.rb: Update json-2.0.2.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-01 03:16:30 +00:00
hsbt
a7b5d45466
* test/lib/test/unit.rb: added test files with _test
suffix for json
...
upstream.
* test/json: merge original test files from json upstream.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-13 13:27:07 +00:00