diff options
| author | Robin Miller <robin@tenjin.ca> | 2025-09-01 22:40:34 -0600 |
|---|---|---|
| committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2025-09-03 23:38:37 +0900 |
| commit | 242680efc5aab477b78b1aaa7299feec5d98bb06 (patch) | |
| tree | 6a4fd09bb7af02be1e7213e5ea8f72ab8e75ef70 /ext/json | |
| parent | 3b38ab9b735f9bc66f66764756978c3d37a57a57 (diff) | |
[ruby/json] Added testing for JSON.unsafe_load. Fixes NoMethodError
when passing proc to JSON.unsafe_load, matching the changes made in
https://github.com/ruby/json/commit/73d2137fd3ad.
https://github.com/ruby/json/commit/77292cbc9b
Diffstat (limited to 'ext/json')
| -rw-r--r-- | ext/json/lib/json/common.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb index 45200a83bc..f8aefcd289 100644 --- a/ext/json/lib/json/common.rb +++ b/ext/json/lib/json/common.rb @@ -703,9 +703,13 @@ module JSON if opts[:allow_blank] && (source.nil? || source.empty?) source = 'null' end - result = parse(source, opts) - recurse_proc(result, &proc) if proc - result + + if proc + opts = opts.dup + opts[:on_load] = proc.to_proc + end + + parse(source, opts) end # :call-seq: |
