From 242680efc5aab477b78b1aaa7299feec5d98bb06 Mon Sep 17 00:00:00 2001 From: Robin Miller Date: Mon, 1 Sep 2025 22:40:34 -0600 Subject: [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 --- ext/json/lib/json/common.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ext/json') 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: -- cgit v1.2.3