#154 Upgrade to Ruby 3.1.4 + Bundler fix
Merged a year ago by jackorp. Opened a year ago by jackorp.
rpms/ jackorp/ruby rebase-ruby-3.1.4  into  f37

@@ -11,7 +11,7 @@ 

  index d261ea57b5..3c13076b82 100644

  --- a/configure.ac

  +++ b/configure.ac

- @@ -3374,6 +3374,11 @@ AS_IF([test ${multiarch+set}], [

+ @@ -3381,6 +3381,11 @@ AS_IF([test ${multiarch+set}], [

   ])

   

   archlibdir='${libdir}/${arch}'

@@ -14,7 +14,7 @@ 

  index c42436c23d..d261ea57b5 100644

  --- a/configure.ac

  +++ b/configure.ac

- @@ -4032,7 +4032,8 @@ AS_CASE(["$ruby_version_dir_name"],

+ @@ -4039,7 +4039,8 @@ AS_CASE(["$ruby_version_dir_name"],

   ruby_version_dir=/'${ruby_version_dir_name}'

   

   if test -z "${ruby_version_dir_name}"; then

@@ -11,7 +11,7 @@ 

  index 3c13076b82..93af30321d 100644

  --- a/configure.ac

  +++ b/configure.ac

- @@ -4096,6 +4096,8 @@ AC_SUBST(vendorarchdir)dnl

+ @@ -4103,6 +4103,8 @@ AC_SUBST(vendorarchdir)dnl

   AC_SUBST(CONFIGURE, "`echo $0 | sed 's|.*/||'`")dnl

   AC_SUBST(configure_args, "`echo "${ac_configure_args}" | sed 's/\\$/$$/g'`")dnl

   

@@ -15,7 +15,7 @@ 

  index 93af30321d..bc13397e0e 100644

  --- a/configure.ac

  +++ b/configure.ac

- @@ -4068,6 +4068,10 @@ AC_ARG_WITH(vendorarchdir,

+ @@ -4075,6 +4075,10 @@ AC_ARG_WITH(vendorarchdir,

               [vendorarchdir=$withval],

               [vendorarchdir=${multiarch+'${rubysitearchprefix}/vendor_ruby'${ruby_version_dir}}${multiarch-'${vendorlibdir}/${sitearch}'}])

   
@@ -26,7 +26,7 @@ 

   AS_IF([test "${LOAD_RELATIVE+set}"], [

       AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)

       RUBY_EXEC_PREFIX=''

- @@ -4092,6 +4096,7 @@ AC_SUBST(sitearchdir)dnl

+ @@ -4099,6 +4104,7 @@ AC_SUBST(sitearchdir)dnl

   AC_SUBST(vendordir)dnl

   AC_SUBST(vendorlibdir)dnl

   AC_SUBST(vendorarchdir)dnl

@@ -20,7 +20,7 @@ 

  index 80b137e380..63cd3b4f8b 100644

  --- a/configure.ac

  +++ b/configure.ac

- @@ -3983,9 +3983,6 @@ AS_CASE(["$target_os"],

+ @@ -3990,9 +3990,6 @@ AS_CASE(["$target_os"],

       rubyw_install_name='$(RUBYW_INSTALL_NAME)'

       ])

   
@@ -30,7 +30,7 @@ 

   rubyarchprefix=${multiarch+'${archlibdir}/${RUBY_BASE_NAME}'}${multiarch-'${rubylibprefix}/${arch}'}

   AC_ARG_WITH(rubyarchprefix,

   	    AS_HELP_STRING([--with-rubyarchprefix=DIR],

- @@ -4008,56 +4005,62 @@ AC_ARG_WITH(ridir,

+ @@ -4015,56 +4015,62 @@ AC_ARG_WITH(ridir,

   AC_SUBST(ridir)

   AC_SUBST(RI_BASE_NAME)

   
@@ -120,7 +120,7 @@ 

   

   AS_IF([test "${LOAD_RELATIVE+set}"], [

       AC_DEFINE_UNQUOTED(LOAD_RELATIVE, $LOAD_RELATIVE)

- @@ -4074,6 +4077,7 @@ AC_SUBST(sitearchincludedir)dnl

+ @@ -4081,6 +4081,7 @@ AC_SUBST(sitearchincludedir)dnl

   AC_SUBST(arch)dnl

   AC_SUBST(sitearch)dnl

   AC_SUBST(ruby_version)dnl

@@ -1,70 +0,0 @@ 

- From a1124dc162810f86cb0bff58cde24064cfc561bc Mon Sep 17 00:00:00 2001

- From: nagachika <nagachika@ruby-lang.org>

- Date: Fri, 9 Dec 2022 21:11:47 +0900

- Subject: [PATCH] merge revision(s) 58cc3c9f387dcf8f820b43e043b540fa06248da3:

-  [Backport #19187]

- 

- 	[Bug #19187] Fix for tzdata-2022g

- 

- 	---

- 	 test/ruby/test_time_tz.rb | 21 +++++++++++++++------

- 	 1 file changed, 15 insertions(+), 6 deletions(-)

- ---

-  test/ruby/test_time_tz.rb | 21 +++++++++++++++------

-  1 files changed, 15 insertions(+), 6 deletions(-)

- 

- diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb

- index b6785f336028d..939f218ed4d10 100644

- --- a/test/ruby/test_time_tz.rb

- +++ b/test/ruby/test_time_tz.rb

- @@ -7,9 +7,9 @@ class TestTimeTZ < Test::Unit::TestCase

-    has_lisbon_tz = true

-    force_tz_test = ENV["RUBY_FORCE_TIME_TZ_TEST"] == "yes"

-    case RUBY_PLATFORM

- -  when /linux/

- +  when /darwin|linux/

-      force_tz_test = true

- -  when /darwin|freebsd|openbsd/

- +  when /freebsd|openbsd/

-      has_lisbon_tz = false

-      force_tz_test = true

-    end

- @@ -95,6 +95,9 @@ def group_by(e, &block)

-    CORRECT_KIRITIMATI_SKIP_1994 = with_tz("Pacific/Kiritimati") {

-      Time.local(1994, 12, 31, 0, 0, 0).year == 1995

-    }

- +  CORRECT_SINGAPORE_1982 = with_tz("Asia/Singapore") {

- +    "2022g" if Time.local(1981, 12, 31, 23, 59, 59).utc_offset == 8*3600

- +  }

-  

-    def time_to_s(t)

-      t.to_s

- @@ -140,9 +143,12 @@ def test_america_managua

-  

-    def test_asia_singapore

-      with_tz(tz="Asia/Singapore") {

- -      assert_time_constructor(tz, "1981-12-31 23:59:59 +0730", :local, [1981,12,31,23,59,59])

- -      assert_time_constructor(tz, "1982-01-01 00:30:00 +0800", :local, [1982,1,1,0,0,0])

- -      assert_time_constructor(tz, "1982-01-01 00:59:59 +0800", :local, [1982,1,1,0,29,59])

- +      assert_time_constructor(tz, "1981-12-31 23:29:59 +0730", :local, [1981,12,31,23,29,59])

- +      if CORRECT_SINGAPORE_1982

- +        assert_time_constructor(tz, "1982-01-01 00:00:00 +0800", :local, [1981,12,31,23,30,00])

- +        assert_time_constructor(tz, "1982-01-01 00:00:00 +0800", :local, [1982,1,1,0,0,0])

- +        assert_time_constructor(tz, "1982-01-01 00:29:59 +0800", :local, [1982,1,1,0,29,59])

- +      end

-        assert_time_constructor(tz, "1982-01-01 00:30:00 +0800", :local, [1982,1,1,0,30,0])

-      }

-    end

- @@ -450,8 +456,11 @@ def self.gen_zdump_test(data)

-  America/Managua  Wed Jan  1 04:59:59 1997 UTC = Tue Dec 31 23:59:59 1996 EST isdst=0 gmtoff=-18000

-  America/Managua  Wed Jan  1 05:00:00 1997 UTC = Tue Dec 31 23:00:00 1996 CST isdst=0 gmtoff=-21600

-  Asia/Singapore  Sun Aug  8 16:30:00 1965 UTC = Mon Aug  9 00:00:00 1965 SGT isdst=0 gmtoff=27000

- -Asia/Singapore  Thu Dec 31 16:29:59 1981 UTC = Thu Dec 31 23:59:59 1981 SGT isdst=0 gmtoff=27000

- +Asia/Singapore  Thu Dec 31 15:59:59 1981 UTC = Thu Dec 31 23:29:59 1981 SGT isdst=0 gmtoff=27000

-  Asia/Singapore  Thu Dec 31 16:30:00 1981 UTC = Fri Jan  1 00:30:00 1982 SGT isdst=0 gmtoff=28800

- +End

- +  gen_zdump_test <<'End' if CORRECT_SINGAPORE_1982

- +Asia/Singapore  Thu Dec 31 16:00:00 1981 UTC = Fri Jan  1 00:00:00 1982 SGT isdst=0 gmtoff=28800

-  End

-    gen_zdump_test CORRECT_TOKYO_DST_1951 ? <<'End' + (CORRECT_TOKYO_DST_1951 < "2018f" ? <<'2018e' : <<'2018f') : <<'End'

-  Asia/Tokyo  Sat May  5 14:59:59 1951 UTC = Sat May  5 23:59:59 1951 JST isdst=0 gmtoff=32400

@@ -0,0 +1,23 @@ 

+ From bffadcd6d46ccfccade79ce0efb60ced8eac4483 Mon Sep 17 00:00:00 2001

+ From: Peter Zhu <peter@peterzhu.ca>

+ Date: Thu, 6 Apr 2023 13:35:25 -0400

+ Subject: [PATCH] Add guard to compaction test in WeakMap

+ 

+ Some platforms don't support compaction, so we should skip this test.

+ ---

+  test/ruby/test_weakmap.rb | 2 ++

+  1 file changed, 2 insertions(+)

+ 

+ diff --git a/test/ruby/test_weakmap.rb b/test/ruby/test_weakmap.rb

+ index c72e7310db101..7fc956dfae474 100644

+ --- a/test/ruby/test_weakmap.rb

+ +++ b/test/ruby/test_weakmap.rb

+ @@ -178,6 +178,8 @@ def test_no_memory_leak

+    end

+  

+    def test_compaction_bug_19529

+ +    omit "compaction is not supported on this platform" unless GC.respond_to?(:compact)

+ +

+      obj = Object.new

+      100.times do |i|

+        GC.compact

@@ -139,7 +139,7 @@ 

  index 1c35856c44..bff0666a17 100644

  --- a/gc.c

  +++ b/gc.c

- @@ -4984,6 +4984,23 @@ gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap)

+ @@ -4985,6 +4985,23 @@ gc_unprotect_pages(rb_objspace_t *objspace, rb_heap_t *heap)

   static void gc_update_references(rb_objspace_t * objspace);

   static void invalidate_moved_page(rb_objspace_t *objspace, struct heap_page *page);

   
@@ -163,7 +163,7 @@ 

   static void

   read_barrier_handler(uintptr_t address)

   {

- @@ -5004,6 +5021,7 @@ read_barrier_handler(uintptr_t address)

+ @@ -5005,6 +5022,7 @@ read_barrier_handler(uintptr_t address)

       }

       RB_VM_LOCK_LEAVE();

   }
@@ -171,7 +171,7 @@ 

   

   #if defined(_WIN32)

   static LPTOP_LEVEL_EXCEPTION_FILTER old_handler;

- @@ -9267,13 +9285,7 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE

+ @@ -9268,13 +9286,7 @@ gc_start_internal(rb_execution_context_t *ec, VALUE self, VALUE full_mark, VALUE

   

       /* For now, compact implies full mark / sweep, so ignore other flags */

       if (RTEST(compact)) {
@@ -186,7 +186,7 @@ 

   

           reason |= GPR_FLAG_COMPACT;

       }

- @@ -9438,7 +9450,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t slot_size)

+ @@ -9439,7 +9451,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t slot_size)

       return (VALUE)src;

   }

   
@@ -195,7 +195,7 @@ 

   static int

   compare_free_slots(const void *left, const void *right, void *dummy)

   {

- @@ -10166,7 +10178,7 @@ gc_update_references(rb_objspace_t *objspace)

+ @@ -10167,7 +10179,7 @@ gc_update_references(rb_objspace_t *objspace)

       gc_update_table_refs(objspace, finalizer_table);

   }

   
@@ -204,7 +204,7 @@ 

   /*

    *  call-seq:

    *     GC.latest_compact_info -> {:considered=>{:T_CLASS=>11}, :moved=>{:T_CLASS=>11}}

- @@ -10207,7 +10219,7 @@ gc_compact_stats(VALUE self)

+ @@ -10208,7 +10220,7 @@ gc_compact_stats(VALUE self)

   #  define gc_compact_stats rb_f_notimplement

   #endif

   
@@ -213,7 +213,7 @@ 

   static void

   root_obj_check_moved_i(const char *category, VALUE obj, void *data)

   {

- @@ -10286,7 +10298,7 @@ gc_compact(VALUE self)

+ @@ -10287,7 +10299,7 @@ gc_compact(VALUE self)

   #  define gc_compact rb_f_notimplement

   #endif

   
@@ -222,7 +222,7 @@ 

   /*

    * call-seq:

    *    GC.verify_compaction_references(toward: nil, double_heap: false) -> hash

- @@ -10817,7 +10829,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

+ @@ -10818,7 +10830,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

       return rb_gc_disable();

   }

   
@@ -231,7 +231,7 @@ 

   /*

    *  call-seq:

    *     GC.auto_compact = flag

- @@ -10831,8 +10843,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

+ @@ -10832,8 +10844,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

   static VALUE

   gc_set_auto_compact(VALUE _, VALUE v)

   {
@@ -241,7 +241,7 @@ 

   

       ruby_enable_autocompact = RTEST(v);

       return v;

- @@ -10841,7 +10852,8 @@ gc_set_auto_compact(VALUE _, VALUE v)

+ @@ -10842,7 +10853,8 @@ gc_set_auto_compact(VALUE _, VALUE v)

   #  define gc_set_auto_compact rb_f_notimplement

   #endif

   
@@ -251,7 +251,7 @@ 

   /*

    *  call-seq:

    *     GC.auto_compact    -> true or false

- @@ -13714,11 +13726,21 @@ Init_GC(void)

+ @@ -13753,11 +13776,21 @@ Init_GC(void)

       rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);

       rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);

   #endif
@@ -278,7 +278,7 @@ 

   

   #if GC_DEBUG_STRESS_TO_CLASS

       rb_define_singleton_method(rb_mGC, "add_stress_to_class", rb_gcdebug_add_stress_to_class, -1);

- @@ -13742,6 +13764,7 @@ Init_GC(void)

+ @@ -13781,6 +13803,7 @@ Init_GC(void)

   	OPT(MALLOC_ALLOCATED_SIZE);

   	OPT(MALLOC_ALLOCATED_SIZE_CHECK);

   	OPT(GC_PROFILE_DETAIL_MEMORY);

@@ -22,7 +22,7 @@ 

  index ef9327df1f..1c35856c44 100644

  --- a/gc.c

  +++ b/gc.c

- @@ -10164,8 +10164,20 @@ gc_update_references(rb_objspace_t *objspace)

+ @@ -10165,8 +10165,20 @@ gc_update_references(rb_objspace_t *objspace)

       gc_update_table_refs(objspace, finalizer_table);

   }

   
@@ -44,7 +44,7 @@ 

   {

       size_t i;

       rb_objspace_t *objspace = &rb_objspace;

- @@ -10238,22 +10250,70 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)

+ @@ -10239,22 +10251,70 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)

       return 0;

   }

   
@@ -120,7 +120,7 @@ 

   

       RB_VM_LOCK_ENTER();

       {

- @@ -10273,12 +10333,12 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do

+ @@ -10274,12 +10334,12 @@ gc_verify_compaction_references(rb_execution_context_t *ec, VALUE self, VALUE do

       }

       RB_VM_LOCK_LEAVE();

   
@@ -135,7 +135,7 @@ 

   }

   

   VALUE

- @@ -10739,8 +10799,18 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

+ @@ -10740,8 +10800,18 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

       return rb_gc_disable();

   }

   
@@ -155,7 +155,7 @@ 

   {

       /* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for

        * the read barrier, so we must disable automatic compaction. */

- @@ -10754,8 +10824,14 @@ gc_set_auto_compact(rb_execution_context_t *ec, VALUE _, VALUE v)

+ @@ -10755,8 +10825,14 @@ gc_set_auto_compact(rb_execution_context_t *ec, VALUE _, VALUE v)

       return v;

   }

   
@@ -171,7 +171,7 @@ 

   {

       return RBOOL(ruby_enable_autocompact);

   }

- @@ -13617,6 +13693,11 @@ Init_GC(void)

+ @@ -13656,6 +13732,11 @@ Init_GC(void)

       rb_define_singleton_method(rb_mGC, "malloc_allocated_size", gc_malloc_allocated_size, 0);

       rb_define_singleton_method(rb_mGC, "malloc_allocations", gc_malloc_allocations, 0);

   #endif
@@ -305,7 +305,7 @@ 

  index 92ed76cf96..d71924846a 100644

  --- a/gc.c

  +++ b/gc.c

- @@ -9438,6 +9438,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t slot_size)

+ @@ -9439,6 +9439,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free, size_t slot_size)

       return (VALUE)src;

   }

   
@@ -313,7 +313,7 @@ 

   static int

   compare_free_slots(const void *left, const void *right, void *dummy)

   {

- @@ -9485,6 +9486,7 @@ gc_sort_heap_by_empty_slots(rb_objspace_t *objspace)

+ @@ -9486,6 +9487,7 @@ gc_sort_heap_by_empty_slots(rb_objspace_t *objspace)

           free(page_list);

       }

   }
@@ -321,7 +321,7 @@ 

   

   static void

   gc_ref_update_array(rb_objspace_t * objspace, VALUE v)

- @@ -10164,6 +10166,7 @@ gc_update_references(rb_objspace_t *objspace)

+ @@ -10165,6 +10167,7 @@ gc_update_references(rb_objspace_t *objspace)

       gc_update_table_refs(objspace, finalizer_table);

   }

   
@@ -329,7 +329,7 @@ 

   /*

    *  call-seq:

    *     GC.latest_compact_info -> {:considered=>{:T_CLASS=>11}, :moved=>{:T_CLASS=>11}}

- @@ -10200,7 +10203,11 @@ gc_compact_stats(VALUE self)

+ @@ -10201,7 +10204,11 @@ gc_compact_stats(VALUE self)

   

       return h;

   }
@@ -341,7 +341,7 @@ 

   static void

   root_obj_check_moved_i(const char *category, VALUE obj, void *data)

   {

- @@ -10262,6 +10269,10 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)

+ @@ -10263,6 +10270,10 @@ heap_check_moved_i(void *vstart, void *vend, size_t stride, void *data)

    *

    * This method is implementation specific and not expected to be implemented

    * in any implementation besides MRI.
@@ -352,7 +352,7 @@ 

    */

   static VALUE

   gc_compact(VALUE self)

- @@ -10271,7 +10282,11 @@ gc_compact(VALUE self)

+ @@ -10272,7 +10283,11 @@ gc_compact(VALUE self)

   

       return gc_compact_stats(self);

   }
@@ -364,7 +364,7 @@ 

   /*

    * call-seq:

    *    GC.verify_compaction_references(toward: nil, double_heap: false) -> hash

- @@ -10340,6 +10355,9 @@ gc_verify_compaction_references(int argc, VALUE *argv, VALUE self)

+ @@ -10341,6 +10356,9 @@ gc_verify_compaction_references(int argc, VALUE *argv, VALUE self)

   

       return gc_compact_stats(self);

   }
@@ -374,7 +374,7 @@ 

   

   VALUE

   rb_gc_start(void)

- @@ -10799,6 +10817,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

+ @@ -10800,6 +10818,7 @@ gc_disable(rb_execution_context_t *ec, VALUE _)

       return rb_gc_disable();

   }

   
@@ -382,7 +382,7 @@ 

   /*

    *  call-seq:

    *     GC.auto_compact = flag

- @@ -10814,16 +10833,15 @@ gc_set_auto_compact(VALUE _, VALUE v)

+ @@ -10815,16 +10834,15 @@ gc_set_auto_compact(VALUE _, VALUE v)

   {

       /* If not MinGW, Windows, or does not have mmap, we cannot use mprotect for

        * the read barrier, so we must disable automatic compaction. */
@@ -403,7 +403,7 @@ 

   /*

    *  call-seq:

    *     GC.auto_compact    -> true or false

- @@ -10835,6 +10853,9 @@ gc_get_auto_compact(VALUE _)

+ @@ -10836,6 +10854,9 @@ gc_get_auto_compact(VALUE _)

   {

       return RBOOL(ruby_enable_autocompact);

   }

@@ -1,38 +0,0 @@ 

- From 656f25987cf2885104d5b13c8d3f5b7d32f1b333 Mon Sep 17 00:00:00 2001

- From: Jean Boussier <jean.boussier@gmail.com>

- Date: Wed, 23 Nov 2022 12:10:36 +0100

- Subject: [PATCH] [ruby/cgi] Fix test_cgi_cookie_new_with_domain to pass on

-  older rubies

- 

- https://github.com/ruby/cgi/commit/05f0c58048

- ---

-  test/cgi/test_cgi_cookie.rb | 8 ++++----

-  1 file changed, 4 insertions(+), 4 deletions(-)

- 

- diff --git a/test/cgi/test_cgi_cookie.rb b/test/cgi/test_cgi_cookie.rb

- index e3ec4bea5286..6d31932d321a 100644

- --- a/test/cgi/test_cgi_cookie.rb

- +++ b/test/cgi/test_cgi_cookie.rb

- @@ -62,18 +62,18 @@ def test_cgi_cookie_new_complex

-  

-    def test_cgi_cookie_new_with_domain

-      h = {'name'=>'name1', 'value'=>'value1'}

- -    cookie = CGI::Cookie.new('domain'=>'a.example.com', **h)

- +    cookie = CGI::Cookie.new(h.merge('domain'=>'a.example.com'))

-      assert_equal('a.example.com', cookie.domain)

-  

- -    cookie = CGI::Cookie.new('domain'=>'1.example.com', **h)

- +    cookie = CGI::Cookie.new(h.merge('domain'=>'1.example.com'))

-      assert_equal('1.example.com', cookie.domain, 'enhanced by RFC 1123')

-  

-      assert_raise(ArgumentError) {

- -      CGI::Cookie.new('domain'=>'-a.example.com', **h)

- +      CGI::Cookie.new(h.merge('domain'=>'-a.example.com'))

-      }

-  

-      assert_raise(ArgumentError) {

- -      CGI::Cookie.new('domain'=>'a-.example.com', **h)

- +      CGI::Cookie.new(h.merge('domain'=>'a-.example.com'))

-      }

-    end

-  

@@ -1,44 +0,0 @@ 

- From 745dcf5326ea2c8e2047a3bddeb0fbb7e7d07649 Mon Sep 17 00:00:00 2001

- From: Xenor Chang <tubaxenor@gmail.com>

- Date: Mon, 28 Nov 2022 12:34:06 +0800

- Subject: [PATCH] [ruby/cgi] Loosen the domain regex to accept '.'

-  (https://github.com/ruby/cgi/pull/29)

- 

- * Loosen the domain regex to accept '.'

- 

- Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>

- 

- https://github.com/ruby/cgi/commit/5e09d632f3

- Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>

- ---

-  lib/cgi/cookie.rb           | 2 +-

-  test/cgi/test_cgi_cookie.rb | 3 +++

-  2 files changed, 4 insertions(+), 1 deletion(-)

- 

- diff --git a/lib/cgi/cookie.rb b/lib/cgi/cookie.rb

- index 1a9c1a82c123..9498e2f9faf9 100644

- --- a/lib/cgi/cookie.rb

- +++ b/lib/cgi/cookie.rb

- @@ -42,7 +42,7 @@ class Cookie < Array

-  

-      TOKEN_RE = %r"\A[[!-~]&&[^()<>@,;:\\\"/?=\[\]{}]]+\z"

-      PATH_VALUE_RE = %r"\A[[ -~]&&[^;]]*\z"

- -    DOMAIN_VALUE_RE = %r"\A(?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\.\g<label>)*\z"

- +    DOMAIN_VALUE_RE = %r"\A\.?(?<label>(?!-)[-A-Za-z0-9]+(?<!-))(?:\.\g<label>)*\z"

-  

-      # Create a new CGI::Cookie object.

-      #

- diff --git a/test/cgi/test_cgi_cookie.rb b/test/cgi/test_cgi_cookie.rb

- index 6d31932d321a..eadae4531365 100644

- --- a/test/cgi/test_cgi_cookie.rb

- +++ b/test/cgi/test_cgi_cookie.rb

- @@ -65,6 +65,9 @@ def test_cgi_cookie_new_with_domain

-      cookie = CGI::Cookie.new(h.merge('domain'=>'a.example.com'))

-      assert_equal('a.example.com', cookie.domain)

-  

- +    cookie = CGI::Cookie.new(h.merge('domain'=>'.example.com'))

- +    assert_equal('.example.com', cookie.domain)

- +

-      cookie = CGI::Cookie.new(h.merge('domain'=>'1.example.com'))

-      assert_equal('1.example.com', cookie.domain, 'enhanced by RFC 1123')

-  

file modified
+37 -23
@@ -1,6 +1,6 @@ 

  %global major_version 3

  %global minor_version 1

- %global teeny_version 3

+ %global teeny_version 4

  %global major_minor_version %{major_version}.%{minor_version}

  

  %global ruby_version %{major_minor_version}.%{teeny_version}
@@ -22,7 +22,7 @@ 

  %endif

  

  

- %global release 174

+ %global release 175

  %{!?release_string:%define release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}}

  

  # The RubyGems library has to stay out of Ruby directory tree, since the
@@ -45,7 +45,7 @@ 

  %global bundler_tmpdir_version 0.1.0

  # TODO: Check the version if/when available in library.

  %global bundler_tsort_version 0.1.1

- %global bundler_uri_version 0.10.1

+ %global bundler_uri_version 0.10.2

  

  %global bigdecimal_version 3.1.1

  %global did_you_mean_version 1.6.1
@@ -169,15 +169,15 @@ 

  # https://github.com/ruby/ruby/pull/5934

  Patch22: ruby-3.2.0-define-unsupported-gc-compaction-methods-as-rb_f_notimplement.patch

  # To regenerate the patch you need to have ruby, autoconf, xz, tar and make installed:

- # tar -Jxvf ./ruby-3.1.3.tar.xz

+ # tar -Jxvf ./ruby-3.1.4.tar.xz

  # git clone https://github.com/ruby/ruby.git

- # cd ruby && git checkout v3_1_3

+ # cd ruby && git checkout v3_1_4

  # patch -p1 < ../ruby-3.2.0-define-unsupported-gc-compaction-methods-as-rb_f_notimplement.patch

  # ./autogen.sh && ./configure

  # make gc.rbinc miniprelude.c

  # cd ..

- # diff -u {ruby-3.1.3,ruby}/gc.rbinc > ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch

- # diff -u {ruby-3.1.3,ruby}/miniprelude.c >> ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch

+ # diff -u {ruby-3.1.4,ruby}/gc.rbinc > ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch

+ # diff -u {ruby-3.1.4,ruby}/miniprelude.c >> ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch

  Patch23: ruby-3.2.0-define-unsupported-gc-compaction-methods_generated-files.patch

  # Define the GC compaction support macro at run time.

  # https://bugs.ruby-lang.org/issues/18829
@@ -190,17 +190,21 @@ 

  # Set soft dependency on RDoc in input-method.rb in IRB.

  # https://github.com/ruby/irb/pull/395

  Patch28: ruby-irb-1.4.1-set-rdoc-soft-dep.patch

- # CGI is now too restrictive about leading '.' in domain, leading to failures

- # in Rack, rack-test or ActionPack.

- # https://github.com/ruby/ruby/commit/656f25987cf2885104d5b13c8d3f5b7d32f1b333

- Patch29: ruby-3.2.0-ruby-cgi-Fix-test_cgi_cookie_new_with_domain-to-pass.patch

- # https://github.com/ruby/cgi/pull/29

- # https://github.com/ruby/ruby/commit/745dcf5326ea2c8e2047a3bddeb0fbb7e7d07649

- Patch30: ruby-3.2.0-ruby-cgi-Loosen-the-domain-regex-to-accept.patch

- # Fix Time Zone Database 2022g.

- # https://bugs.ruby-lang.org/issues/19187

- # https://github.com/ruby/ruby/commit/a1124dc162810f86cb0bff58cde24064cfc561bc

- Patch31: ruby-3.1.3-Fix-for-tzdata-2022g.patch

+ # A Weakmap test uses compaction without safeguarding if the method is defined.

+ # This test should be skipped if compaction is not supported on the platform.

+ # https://github.com/ruby/ruby/commit/bffadcd6d46ccfccade79ce0efb60ced8eac4483

+ # https://bugs.ruby-lang.org/issues/19529#note-7

+ Patch29: ruby-3.1.4-Skip-test_compaction_bug_19529-if-compaction-unsupported.patch

+ # Bundler does not correctly resolve archful gems in 2.3.26.

+ # Example of such an issue

+ # https://github.com/sclorg/s2i-ruby-container/issues/469

+ # The patch is an amalgamation of the following:

+ # https://github.com/rubygems/rubygems/pull/6225

+ # https://github.com/rubygems/rubygems/commit/7b64c64262a7a980c0eb23b96ea56cf72ea06e89

+ # Backport requested in

+ # https://bugs.ruby-lang.org/issues/19576

+ Patch30: rubygem-bundler-2.3.26-Provide-fix-for-bundler-Gemfile-resolving-regression.patch

+ Patch31: rubygem-bundler-2.3.26-Tests-from-bundler-PR-6225.patch

  

  Requires: %{name}-libs%{?_isa} = %{version}-%{release}

  Suggests: rubypick
@@ -673,8 +677,11 @@ 

  %patch27 -p1

  %patch28 -p1

  %patch29 -p1

- %patch30 -p1

- %patch31 -p1

+ %patch30 -p2

+ 

+ pushd spec/bundler

+ %patch31 -p3

+ popd

  

  # Provide an example of usage of the tapset:

  cp -a %{SOURCE3} .
@@ -1249,7 +1256,7 @@ 

  %{gem_dir}/specifications/default/abbrev-0.1.0.gemspec

  %{gem_dir}/specifications/default/base64-0.1.1.gemspec

  %{gem_dir}/specifications/default/benchmark-0.2.0.gemspec

- %{gem_dir}/specifications/default/cgi-0.3.5.gemspec

+ %{gem_dir}/specifications/default/cgi-0.3.6.gemspec

  %{gem_dir}/specifications/default/csv-3.2.5.gemspec

  %{gem_dir}/specifications/default/date-3.2.2.gemspec

  %{gem_dir}/specifications/default/delegate-0.2.0.gemspec
@@ -1300,12 +1307,12 @@ 

  %{gem_dir}/specifications/default/strscan-3.0.1.gemspec

  %{gem_dir}/specifications/default/syslog-0.1.0.gemspec

  %{gem_dir}/specifications/default/tempfile-0.1.2.gemspec

- %{gem_dir}/specifications/default/time-0.2.0.gemspec

+ %{gem_dir}/specifications/default/time-0.2.2.gemspec

  %{gem_dir}/specifications/default/timeout-0.2.0.gemspec

  %{gem_dir}/specifications/default/tmpdir-0.1.2.gemspec

  %{gem_dir}/specifications/default/tsort-0.1.0.gemspec

  %{gem_dir}/specifications/default/un-0.2.0.gemspec

- %{gem_dir}/specifications/default/uri-0.11.0.gemspec

+ %{gem_dir}/specifications/default/uri-0.12.1.gemspec

  %{gem_dir}/specifications/default/weakref-0.1.1.gemspec

  #%%{gem_dir}/specifications/default/win32ole-1.8.8.gemspec

  %{gem_dir}/specifications/default/yaml-0.2.0.gemspec
@@ -1545,6 +1552,13 @@ 

  

  

  %changelog

+ * Fri Mar 31 2023 Jarek Prokop jprokop@redhat.com - 3.1.4-175

+ - Upgrade to Ruby 3.1.4.

+ - Fix ReDoS vulnerability in URI (CVE-2023-28755)

+ - Fix ReDoS vulnerability in Time (CVE-2023-28756)

+ - Fix bundler improperly resolving archful gems in Gemfile.lock.

+   Resolves: rhbz#2178171

+ 

  * Fri Jan 20 2023 Jun Aruga <jaruga@redhat.com> - 3.1.3-174

  - Fix for tzdata-2022g.

  

@@ -0,0 +1,144 @@ 

+ From 0985592ad2d815ac461100807f5b2621e5f49b21 Mon Sep 17 00:00:00 2001

+ From: Jarek Prokop <jprokop@redhat.com>

+ Date: Fri, 31 Mar 2023 11:54:07 +0200

+ Subject: [PATCH 1/2] Provide fix for bundler Gemfile resolving regression.

+ 

+ Instead of resolving to correct Ruby platform, it preferred the

+ archful package, that is actually incompatible.

+ 

+ See https://github.com/sclorg/s2i-ruby-container/issues/469

+ for an example of the bug.

+ 

+ Commit taken from:

+ <https://github.com/rubygems/rubygems/pull/6225>

+ and adapted:

+ <https://github.com/rubygems/rubygems/commit/7b64c64262a7a980c0eb23b96ea56cf72ea06e89>

+ for the PR#6225.

+ ---

+  bundler/lib/bundler/index.rb              |  5 ++

+  bundler/lib/bundler/lazy_specification.rb | 64 ++++++++++-------------

+  2 files changed, 34 insertions(+), 35 deletions(-)

+ 

+ diff --git a/bundler/lib/bundler/index.rb b/bundler/lib/bundler/index.rb

+ index ed16c90a3..903e220d5 100644

+ --- a/bundler/lib/bundler/index.rb

+ +++ b/bundler/lib/bundler/index.rb

+ @@ -71,6 +71,7 @@ def local_search(query)

+        when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)

+        when String then specs_by_name(query)

+        when Gem::Dependency then search_by_dependency(query)

+ +      when Array then search_by_name_and_version(*query)

+        else

+          raise "You can't search for a #{query.inspect}."

+        end

+ @@ -173,6 +174,10 @@ def search_by_dependency(dependency)

+        end

+      end

+  

+ +    def search_by_name_and_version(name, version)

+ +      specs_by_name(name).select { |spec| spec.version == version }

+ +    end

+ +

+      EMPTY_SEARCH = [].freeze

+  

+      def search_by_spec(spec)

+ diff --git a/bundler/lib/bundler/lazy_specification.rb b/bundler/lib/bundler/lazy_specification.rb

+ index 949e8264b..e8bee25ab 100644

+ --- a/bundler/lib/bundler/lazy_specification.rb

+ +++ b/bundler/lib/bundler/lazy_specification.rb

+ @@ -13,7 +13,6 @@ def initialize(name, version, platform, source = nil)

+        @dependencies  = []

+        @platform      = platform || Gem::Platform::RUBY

+        @source        = source

+ -      @specification = nil

+      end

+  

+      def full_name

+ @@ -76,37 +75,41 @@ def to_lock

+      def materialize_for_installation

+        source.local!

+  

+ -      candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?

+ -        target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform

+ +      matching_specs = source.specs.search(use_exact_resolved_specifications? ? self : [name, version])

+ +      return self if matching_specs.empty?

+  

+ -        GemHelpers.select_best_platform_match(source.specs.search(Dependency.new(name, version)), target_platform)

+ -      else

+ -        source.specs.search(self)

+ -      end

+ +      candidates = if use_exact_resolved_specifications?

+ +                     matching_specs

+ +                   else

+ +                     target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform

+ +

+ +                     installable_candidates = GemHelpers.select_best_platform_match(matching_specs, target_platform)

+ +

+ +                     specification = __materialize__(installable_candidates)

+ +                     return specification unless specification.nil?

+  

+ -      return self if candidates.empty?

+ +                     if target_platform != platform

+ +                       installable_candidates = GemHelpers.select_best_platform_match(matching_specs, platform)

+ +                     end

+ +

+ +                     installable_candidates

+ +                   end

+  

+        __materialize__(candidates)

+      end

+  

+      def __materialize__(candidates)

+ -      @specification = begin

+ -        search = candidates.reverse.find do |spec|

+ -          spec.is_a?(StubSpecification) ||

+ -            (spec.matches_current_ruby? &&

+ -              spec.matches_current_rubygems?)

+ -        end

+ -        if search.nil? && Bundler.frozen_bundle?

+ -          search = candidates.last

+ -        else

+ -          search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))

+ -        end

+ -        search

+ +      search = candidates.reverse.find do |spec|

+ +        spec.is_a?(StubSpecification) ||

+ +          (spec.matches_current_ruby? &&

+ +           spec.matches_current_rubygems?)

+        end

+ -    end

+ -

+ -    def respond_to?(*args)

+ -      super || @specification ? @specification.respond_to?(*args) : nil

+ +      if search.nil? && Bundler.frozen_bundle?

+ +        search = candidates.last

+ +      else

+ +        search.dependencies = dependencies if search && search.full_name == full_name && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))

+ +      end

+ +      search

+      end

+  

+      def to_s

+ @@ -127,17 +130,8 @@ def git_version

+      end

+  

+      private

+ -

+ -    def to_ary

+ -      nil

+ -    end

+ -

+ -    def method_missing(method, *args, &blk)

+ -      raise "LazySpecification has not been materialized yet (calling :#{method} #{args.inspect})" unless @specification

+ -

+ -      return super unless respond_to?(method)

+ -

+ -      @specification.send(method, *args, &blk)

+ +    def use_exact_resolved_specifications?

+ +      @use_exact_resolved_specifications ||= !source.is_a?(Source::Path) && ruby_platform_materializes_to_ruby_platform?

+      end

+  

+      #

+ -- 

+ 2.40.0

+ 

@@ -0,0 +1,60 @@ 

+ From cb3d287a91e9b6762e47635137d6024fe39e117d Mon Sep 17 00:00:00 2001

+ From: Jarek Prokop <jprokop@redhat.com>

+ Date: Fri, 31 Mar 2023 12:06:21 +0200

+ Subject: [PATCH] Tests from bundler's PR#6225.

+ 

+ See <https://github.com/rubygems/rubygems/pull/6225>.

+ ---

+  .../install/gemfile/specific_platform_spec.rb | 36 +++++++++++++++++++

+  1 file changed, 36 insertions(+)

+ 

+ diff --git a/bundler/spec/install/gemfile/specific_platform_spec.rb b/bundler/spec/install/gemfile/specific_platform_spec.rb

+ index 98efec396..a29446305 100644

+ --- a/bundler/spec/install/gemfile/specific_platform_spec.rb

+ +++ b/bundler/spec/install/gemfile/specific_platform_spec.rb

+ @@ -104,6 +104,42 @@

+        L

+      end

+  

+ +    it "still installs the generic RUBY variant if necessary even when running on a legacy lockfile locked only to RUBY" do

+ +      build_repo4 do

+ +        build_gem "nokogiri", "1.3.10"

+ +        build_gem "nokogiri", "1.3.10" do |s|

+ +          s.platform = "arm64-darwin"

+ +          s.required_ruby_version = "< #{Gem.ruby_version}"

+ +        end

+ +

+ +        build_gem "bundler", "2.1.4"

+ +      end

+ +

+ +      gemfile <<~G

+ +        source "#{file_uri_for(gem_repo4)}"

+ +        gem "nokogiri"

+ +      G

+ +

+ +      lockfile <<-L

+ +        GEM

+ +          remote: #{file_uri_for(gem_repo4)}/

+ +          specs:

+ +            nokogiri (1.3.10)

+ +        PLATFORMS

+ +          ruby

+ +        DEPENDENCIES

+ +          nokogiri

+ +        RUBY VERSION

+ +          2.5.3p105

+ +        BUNDLED WITH

+ +           2.1.4

+ +      L

+ +

+ +      simulate_platform "arm64-darwin-22" do

+ +        bundle "update --bundler", :artifice => "compact_index", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }

+ +      end

+ +    end

+ +

+      it "doesn't discard previously installed platform specific gem and fall back to ruby on subsequent bundles" do

+        build_repo2 do

+          build_gem("libv8", "8.4.255.0")

+ -- 

+ 2.40.0

+ 

file modified
+1 -1
@@ -1,1 +1,1 @@ 

- SHA512 (ruby-3.1.3.tar.xz) = 4b0fd334ae56132ba98b8a69adad54bdcf7f7aeabd5eba5b0f0399a3868e2054f9026ca1b1cb2dbb197a9e9b0610b263481949c0623a62071546bc5adff8ca69

+ SHA512 (ruby-3.1.4.tar.xz) = a627bb629a10750b8b2081ad451a41faea0fc85d95aa1e267e3d2a0f56a35bb58195d4a8d13bbdbd82f4197a96dae22b1cee1dfc83861ec33a67ece07aef5633

Upgrade to latest Ruby 3.1 release in Fedora 37. This will be ported to F36 after this PR is merged.

CGI and timezone patches were deleted as they were backported and changes are present in Ruby 3.1.4.

This also brings a fix for rhbz#2178171, which describes bundler's failure to correctly resolve archful gem that restricts ruby version, to a archless (ruby platform) gem that gets built locally. However, the fix is a fusion of a PR and a Commit, from what I can tell, bundler still works correctly, but I never really personally cared about pre-built gems, so I haven't tested it in detail. On the other hand, bundler test suite passes, see logs from my local build: https://gist.github.com/jackorp/390e9d3c69934782aaa2fe5bb6af944f

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/2a5d88f3ed954c24a86b209ea0c6af34

Could you please report this to bugs.ruby-lang.org, so we can ask for backport? Or is there any relevant ticket already?

Actually, there is build failure on PPC:

  1) Error:
TestWeakMap#test_compaction_bug_19529:
NotImplementedError: compact() function is unimplemented on this machine

I am not sure I have ever seen this error before. Is this new test case? Or is this test case just flaky?

Actually, there is build failure on PPC:

1) Error:
TestWeakMap#test_compaction_bug_19529:
NotImplementedError: compact() function is unimplemented on this machine

I am not sure I have ever seen this error before. Is this new test case? Or is this test case just flaky?

(Backported) new test.
https://github.com/ruby/ruby/commit/cd4a997e53a02e5a8b24e38a10ba5525c176980e

I am not sure I have ever seen this error before. Is this new test case? Or is this test case just flaky?

This comes from the GC fix for ppc64le I worked on, to prevent it all from locking up in some circumstances. Seeing this means the patches are working, but there is apparently a new test case, seeing by that bug number that it's recent. I'll check out what can be done about it.

Could you please report this to bugs.ruby-lang.org, so we can ask for backport? Or is there any relevant ticket already?

Right, asking for backport makes sense. I am not aware of any relevant ticket on ruby langs, but I have searched only

(Backported) new test.

Thanks for linking it. Hmm, usually compaction related tests were outright skipped unless compaction is supported on platform. I think that skip is missing there.

rebased onto 4ed411904ad865dd3c3041c1d7a86defda46dea5

a year ago

Asked for backport: https://bugs.ruby-lang.org/issues/19576

Worked around the GC compaction.

I'll wait for CI build results to re-confirm it is OK and then merge.

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/368f9bacb51e4e66b5b3b4e2ffbe3b6e

Link please?

I might've looked on the wrong Ruby version...
https://docs.ruby-lang.org/en/3.2/GC.html#method-c-compact

The Ruby 3.1 https://docs.ruby-lang.org/en/3.1/GC.html#method-c-compact
states nothing of the sorts...

It works, OTOH, it might be better to just skip the test with %ifarch ppc64le

Link please?

I might've looked on the wrong Ruby version...
https://docs.ruby-lang.org/en/3.2/GC.html#method-c-compact

The Ruby 3.1 https://docs.ruby-lang.org/en/3.1/GC.html#method-c-compact
states nothing of the sorts...

It works, OTOH, it might be better to just skip the test with %ifarch ppc64le

I had on my mind link to upstream issue, which would address this without action on our side. Sorry for not being more specific.

rebased onto cc651a7a2c5df8e2a8f5497d6ec426144222a1c6

a year ago

I had on my mind link to upstream issue, which would address this without action on our side. Sorry for not being more specific.

I added a note on the backport request that brought the test in.

https://bugs.ruby-lang.org/issues/19529#note-7

Builds sometimes fails on 32bit intel on JIT header compilation, already reported at: https://bugzilla.redhat.com/show_bug.cgi?id=2125026

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/2ba03bfd643e4906a85fa90f480989b8

2 new commits added

  • Fix bundler improperly resolving archful gems in Gemfile.lock.
  • Upgrade to Ruby 3.1.4.
a year ago

rebased onto c4f2964

a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/89b558715fd6404fb3d21a576d6f4dbb

I have replaced the sed in tests disabling the failing test noted in this PR by an upstream patch:
https://bugs.ruby-lang.org/issues/19529#note-8

As well as added a note about the backport request for bundler. As I have addressed points raised in this PR I'll go ahead and merge.

Pull-Request has been merged by jackorp

a year ago