public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
To: git-commits@fedoraproject.org
Subject: [rpms/rubygem-activerecord] rawhide: Backport upstream fix for compatibility with json 3.0
Date: Tue, 22 Sep 2026 03:30:44 GMT	[thread overview]
Message-ID: <179004784413.1.9906407792262329197.rpms-rubygem-activerecord-38a4e007ebdb@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/rubygem-activerecord
Branch : rawhide
Commit : 38a4e007ebdb00fc45ee4bfdf0b6465f4b61d913
Author : Mamoru TASAKA <mtasaka@fedoraproject.org>
Date   : 2026-09-22T12:28:36+09:00
Stats  : +122/-4 in 3 file(s)
URL    : https://src.fedoraproject.org/rpms/rubygem-activerecord/c/38a4e007ebdb00fc45ee4bfdf0b6465f4b61d913?branch=rawhide

Log:
Backport upstream fix for compatibility with json 3.0

---
diff --git a/rubygem-activerecord-8.1.3.1-Fix-MessageSerializerTest-for-json3.patch b/rubygem-activerecord-8.1.3.1-Fix-MessageSerializerTest-for-json3.patch
new file mode 100644
index 0000000..1ca7a3a
--- /dev/null
+++ b/rubygem-activerecord-8.1.3.1-Fix-MessageSerializerTest-for-json3.patch
@@ -0,0 +1,31 @@
+From ec449c1bab6385abe56bbffbb12058c390ed9693 Mon Sep 17 00:00:00 2001
+From: Jean Boussier <jean.boussier@gmail.com>
+Date: Mon, 7 Sep 2026 16:07:01 +0100
+Subject: [PATCH] Fix MessageSerializerTest to handle json 3.x
+
+`JSON.load` is no longer a vulnerability.
+---
+ .../test/cases/encryption/message_serializer_test.rb     | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/activerecord/test/cases/encryption/message_serializer_test.rb b/activerecord/test/cases/encryption/message_serializer_test.rb
+index db81ad74a7f31..a8bebb5e292cf 100644
+--- a/activerecord/test/cases/encryption/message_serializer_test.rb
++++ b/activerecord/test/cases/encryption/message_serializer_test.rb
+@@ -23,9 +23,14 @@ class ActiveRecord::Encryption::MessageSerializerTest < ActiveRecord::Encryption
+   end
+ 
+   test "won't load classes from JSON" do
+-    class_loading_payload = JSON.dump({ p: ::Base64.strict_encode64("Some payload"), json_class: "MessageSerializerTest::SomeClassThatWillNeverExist" })
++    data = { p: ::Base64.strict_encode64("Some payload"), json_class: "MessageSerializerTest::SomeClassThatWillNeverExist" }
++    class_loading_payload = JSON.dump(data)
+ 
+-    assert_raises(ArgumentError) { JSON.load(class_loading_payload) }
++    if JSON::VERSION < "3"
++      assert_raises(ArgumentError) { JSON.load(class_loading_payload) }
++    else
++      assert_equal(data.stringify_keys, JSON.load(class_loading_payload))
++    end
+     assert_nothing_raised { @serializer.load(class_loading_payload) }
+   end
+ 

diff --git a/rubygem-activerecord-pr58601-json3-compat.patch b/rubygem-activerecord-pr58601-json3-compat.patch
new file mode 100644
index 0000000..0f85ce5
--- /dev/null
+++ b/rubygem-activerecord-pr58601-json3-compat.patch
@@ -0,0 +1,73 @@
+From 976337a3c1c5e9745e7aef7191d28470d1621914 Mon Sep 17 00:00:00 2001
+From: Earlopain <14981592+Earlopain@users.noreply.github.com>
+Date: Fri, 28 Aug 2026 18:05:42 +0200
+Subject: [PATCH 2/2] Fix compatibility with json 3.0 in activerecord
+
+`escape` is not valid for `JSON.parse`, activesupport has its own
+special handling for `as_json` stuff
+
+`ActiveRecord::Coders::JSON` is nodoc but was explicitly made to support
+options in https://github.com/rails/rails/commit/65426afea6141bb489ee02d1513fe2c14b700700
+Maybe it's ok? Not sure.
+---
+ activerecord/lib/active_record/coders/json.rb        | 11 ++++++-----
+ activerecord/test/cases/coders/json_test.rb          |  2 +-
+ activerecord/test/cases/serialized_attribute_test.rb |  2 +-
+ 3 files changed, 8 insertions(+), 7 deletions(-)
+
+diff --git a/activerecord/lib/active_record/coders/json.rb b/activerecord/lib/active_record/coders/json.rb
+index 6a7cbab118749..3382e2bad2407 100644
+--- a/activerecord/lib/active_record/coders/json.rb
++++ b/activerecord/lib/active_record/coders/json.rb
+@@ -5,11 +5,12 @@
+ module ActiveRecord
+   module Coders # :nodoc:
+     class JSON # :nodoc:
+-      DEFAULT_OPTIONS = { escape: false }.freeze
++      DEFAULT_ENCODE_OPTIONS = { escape: false }.freeze
+ 
+-      def initialize(options = nil)
+-        @options = options ? DEFAULT_OPTIONS.merge(options) : DEFAULT_OPTIONS
+-        @encoder = ActiveSupport::JSON::Encoding.json_encoder.new(options)
++      def initialize(encode_options: nil, decode_options: nil)
++        encode_options = encode_options ? DEFAULT_ENCODE_OPTIONS.merge(options) : DEFAULT_ENCODE_OPTIONS
++        @decode_options = decode_options
++        @encoder = ActiveSupport::JSON::Encoding.json_encoder.new(encode_options)
+       end
+ 
+       def dump(obj)
+@@ -17,7 +18,7 @@ def dump(obj)
+       end
+ 
+       def load(json)
+-        ActiveSupport::JSON.decode(json, @options) unless json.blank?
++        ActiveSupport::JSON.decode(json, @decode_options) unless json.blank?
+       end
+     end
+   end
+diff --git a/activerecord/test/cases/coders/json_test.rb b/activerecord/test/cases/coders/json_test.rb
+index d0d1d6a6e61f0..6285233dac063 100644
+--- a/activerecord/test/cases/coders/json_test.rb
++++ b/activerecord/test/cases/coders/json_test.rb
+@@ -16,7 +16,7 @@ def test_returns_nil_if_nil_given
+       end
+ 
+       def test_coder_with_symbolize_names
+-        coder = JSON.new(symbolize_names: true)
++        coder = JSON.new(decode_options: { symbolize_names: true })
+         assert_equal({ foo: "bar" }, coder.load('{"foo":"bar"}'))
+       end
+     end
+diff --git a/activerecord/test/cases/serialized_attribute_test.rb b/activerecord/test/cases/serialized_attribute_test.rb
+index d995f2f6c9f78..31f753d198524 100644
+--- a/activerecord/test/cases/serialized_attribute_test.rb
++++ b/activerecord/test/cases/serialized_attribute_test.rb
+@@ -156,7 +156,7 @@ def test_json_type_hash_default_value
+   end
+ 
+   def test_json_symbolize_names_returns_symbolized_names
+-    Topic.serialize :content, coder: ActiveRecord::Coders::JSON.new(symbolize_names: true)
++    Topic.serialize :content, coder: ActiveRecord::Coders::JSON.new(decode_options: { symbolize_names: true })
+     my_post = posts(:welcome)
+ 
+     t = Topic.new(content: my_post)

diff --git a/rubygem-activerecord.spec b/rubygem-activerecord.spec
index efdba06..579c3d6 100644
--- a/rubygem-activerecord.spec
+++ b/rubygem-activerecord.spec
@@ -4,7 +4,7 @@
 Name: rubygem-%{gem_name}
 Epoch: 1
 Version: 8.1.3.1
-Release: 1%{?dist}
+Release: 2%{?dist}
 Summary: Object-relational mapper framework (part of Rails)
 License: MIT
 URL: https://rubyonrails.org
@@ -12,6 +12,13 @@ Source0: https://rubygems.org/gems/%{gem_name}-%{version}%{?prerelease}.gem
 # git clone http://github.com/rails/rails.git && cd rails/activerecord
 # git archive -v -o activerecord-8.1.3.1-tests.tar.gz v8.1.3.1 test/
 Source1: activerecord-%{version}%{?prerelease}-tests.tar.gz
+# Fix compatibility with json 3.0
+# https://github.com/rails/rails/pull/58601
+# (partly: https://github.com/rails/rails/pull/57991 )
+Patch1: rubygem-activerecord-pr58601-json3-compat.patch
+# Fix MessageSerializerTest to handle json 3.x
+# https://github.com/rails/rails/commit/ec449c1bab6385abe56bbffbb12058c390ed9693
+Patch2: rubygem-activerecord-8.1.3.1-Fix-MessageSerializerTest-for-json3.patch
 
 # Database dump/load reuires the executable.
 Suggests: %{_bindir}/sqlite3
@@ -44,7 +51,10 @@ BuildArch: noarch
 Documentation for %{name}.
 
 %prep
-%setup -q -n %{gem_name}-%{version}%{?prerelease} -b 1
+%setup -q -n %{gem_name}-%{version}%{?prerelease} -a 1
+
+%patch 1 -p2
+%patch 2 -p2
 
 %build
 gem build ../%{gem_name}-%{version}%{?prerelease}.gemspec
@@ -57,8 +67,9 @@ cp -a .%{gem_dir}/* \
         %{buildroot}%{gem_dir}/
 
 %check
-( cd .%{gem_instdir}
-cp -a %{builddir}/test .
+(
+cp -a test .%{gem_instdir}
+cd .%{gem_instdir}
 
 mkdir ../tools
 # Fake strict_warnings.rb. It does not appear to be useful.
@@ -96,6 +107,9 @@ done
 %{gem_instdir}/examples
 
 %changelog
+* Fri Sep 11 2026 Mamoru TASAKA <mtasaka@fedoraproject.org> - 1:8.1.3.1-2
+- Backport upstream fix for compatibility with json 3.0
+
 * Mon Aug 03 2026 Vít Ondruch <vondruch@redhat.com> - 1:8.1.3.1-1
 - Update to Active Record 8.1.3.1.
   Related: rhzb#2405582

                 reply	other threads:[~2026-09-22  3:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179004784413.1.9906407792262329197.rpms-rubygem-activerecord-38a4e007ebdb@fedoraproject.org \
    --to=mtasaka@fedoraproject.org \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox