diff --git a/backport-rdoc-Allow-partial-default-values-to-be-overridden.patch b/backport-rdoc-Allow-partial-default-values-to-be-overridden.patch new file mode 100644 index 0000000000000000000000000000000000000000..827d5e10bcbb039bb1e040193f5ae7747ce61e08 --- /dev/null +++ b/backport-rdoc-Allow-partial-default-values-to-be-overridden.patch @@ -0,0 +1,111 @@ +From 971a0cd246db6578e1ea8760a903e1a23e3681f3 Mon Sep 17 00:00:00 2001 +From: aycabta +Date: Sun, 7 Mar 2021 10:13:14 +0900 +Subject: [PATCH] [ruby/rdoc] Allow partial default values to be overridden + with .rdoc_options + +https://github.com/ruby/rdoc/commit/e14800891f +https://github.com/ruby/ruby/commit/971a0cd246db6578e1ea8760a903e1a23e3681f3 +--- + lib/rdoc/options.rb | 34 +++++++++++++++++++++++++++++++++- + lib/rdoc/rdoc.rb | 7 ++++++- + test/rdoc/test_rdoc_rdoc.rb | 12 ++++++++++++ + 3 files changed, 51 insertions(+), 2 deletions(-) + +diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb +index 99d7aaa..dc6a018 100644 +--- a/lib/rdoc/options.rb ++++ b/lib/rdoc/options.rb +@@ -338,8 +338,9 @@ class RDoc::Options + + attr_reader :visibility + +- def initialize # :nodoc: ++ def initialize loaded_options = nil # :nodoc: + init_ivars ++ override loaded_options if loaded_options + end + + def init_ivars # :nodoc: +@@ -414,6 +415,37 @@ class RDoc::Options + init_with map + end + ++ def override map # :nodoc: ++ if map.has_key?('encoding') ++ encoding = map['encoding'] ++ @encoding = encoding ? Encoding.find(encoding) : encoding ++ end ++ ++ @charset = map['charset'] if map.has_key?('charset') ++ @exclude = map['exclude'] if map.has_key?('exclude') ++ @generator_name = map['generator_name'] if map.has_key?('generator_name') ++ @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all') ++ @line_numbers = map['line_numbers'] if map.has_key?('line_numbers') ++ @locale_name = map['locale_name'] if map.has_key?('locale_name') ++ @locale_dir = map['locale_dir'] if map.has_key?('locale_dir') ++ @main_page = map['main_page'] if map.has_key?('main_page') ++ @markup = map['markup'] if map.has_key?('markup') ++ @op_dir = map['op_dir'] if map.has_key?('op_dir') ++ @show_hash = map['show_hash'] if map.has_key?('show_hash') ++ @tab_width = map['tab_width'] if map.has_key?('tab_width') ++ @template_dir = map['template_dir'] if map.has_key?('template_dir') ++ @title = map['title'] if map.has_key?('title') ++ @visibility = map['visibility'] if map.has_key?('visibility') ++ @webcvs = map['webcvs'] if map.has_key?('webcvs') ++ ++ if map.has_key?('rdoc_include') ++ @rdoc_include = sanitize_path map['rdoc_include'] ++ end ++ if map.has_key?('static_path') ++ @static_path = sanitize_path map['static_path'] ++ end ++ end ++ + def == other # :nodoc: + self.class === other and + @encoding == other.encoding and +diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb +index 0089fe9..5cf52ff 100644 +--- a/lib/rdoc/rdoc.rb ++++ b/lib/rdoc/rdoc.rb +@@ -168,7 +168,12 @@ class RDoc::RDoc + end + + raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless +- RDoc::Options === options ++ RDoc::Options === options or Hash === options ++ ++ if Hash === options ++ # Override the default values with the contents of YAML file. ++ options = RDoc::Options.new options ++ end + + options + end +diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb +index c9b55fa..3516aa4 100644 +--- a/test/rdoc/test_rdoc_rdoc.rb ++++ b/test/rdoc/test_rdoc_rdoc.rb +@@ -128,6 +128,18 @@ class TestRDocRDoc < RDoc::TestCase + end + end + ++ def test_load_options_partial_override ++ temp_dir do ++ File.open '.rdoc_options', 'w' do |io| ++ io.write "markup: Markdown" ++ end ++ ++ options = @rdoc.load_options ++ ++ assert_equal 'Markdown', options.markup ++ end ++ end ++ + def load_options_no_file + temp_dir do + options = @rdoc.load_options +-- +2.43.0 + diff --git a/backport-rdoc-Dump-plain-objects-as-RDoc-Options.patch b/backport-rdoc-Dump-plain-objects-as-RDoc-Options.patch new file mode 100644 index 0000000000000000000000000000000000000000..6c457d1066eb35be6eaf6fed685a7167e7e91865 --- /dev/null +++ b/backport-rdoc-Dump-plain-objects-as-RDoc-Options.patch @@ -0,0 +1,323 @@ +From 3b3fb73d6107f64b4c71472de36c4debaf41cd42 Mon Sep 17 00:00:00 2001 +From: Nobuyoshi Nakada +Date: Wed, 15 Sep 2021 17:26:14 +0900 +Subject: [PATCH] [ruby/rdoc] Dump plain objects as `RDoc::Options` + +So that the generated `.rdoc_options` file is loadable. + +https://github.com/ruby/rdoc/commit/6cf6e1647b +https://github.com/ruby/ruby/commit/3b3fb73d6107f64b4c71472de36c4debaf41cd42 +--- + lib/rdoc/options.rb | 39 ++++++++++++++++--------------- + lib/rdoc/rdoc.rb | 2 +- + test/rdoc/test_rdoc_options.rb | 42 ++++++++++++++++++++++------------ + test/rdoc/test_rdoc_rdoc.rb | 11 ++++++++- + 4 files changed, 60 insertions(+), 34 deletions(-) + +diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb +index 4e60540..b88ca3f 100644 +--- a/lib/rdoc/options.rb ++++ b/lib/rdoc/options.rb +@@ -106,6 +106,7 @@ class RDoc::Options + generator_options + generators + op_dir ++ page_dir + option_parser + pipe + rdoc_include +@@ -431,6 +432,7 @@ class RDoc::Options + @main_page = map['main_page'] if map.has_key?('main_page') + @markup = map['markup'] if map.has_key?('markup') + @op_dir = map['op_dir'] if map.has_key?('op_dir') ++ @page_dir = map['page_dir'] if map.has_key?('page_dir') + @show_hash = map['show_hash'] if map.has_key?('show_hash') + @tab_width = map['tab_width'] if map.has_key?('tab_width') + @template_dir = map['template_dir'] if map.has_key?('template_dir') +@@ -510,19 +512,22 @@ class RDoc::Options + ## + # For dumping YAML + +- def encode_with coder # :nodoc: ++ def to_yaml(*options) # :nodoc: + encoding = @encoding ? @encoding.name : nil + +- coder.add 'encoding', encoding +- coder.add 'static_path', sanitize_path(@static_path) +- coder.add 'rdoc_include', sanitize_path(@rdoc_include) ++ yaml = {} ++ yaml['encoding'] = encoding ++ yaml['static_path'] = sanitize_path(@static_path) ++ yaml['rdoc_include'] = sanitize_path(@rdoc_include) ++ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir) + + ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] } + ivars -= SPECIAL + + ivars.sort.each do |ivar| +- coder.add ivar, instance_variable_get("@#{ivar}") ++ yaml[ivar] = instance_variable_get("@#{ivar}") + end ++ yaml.to_yaml + end + + ## +@@ -531,6 +536,11 @@ class RDoc::Options + # #template. + + def finish ++ if @write_options then ++ write_options ++ exit ++ end ++ + @op_dir ||= 'doc' + + @rdoc_include << "." if @rdoc_include.empty? +@@ -574,14 +584,14 @@ class RDoc::Options + def finish_page_dir + return unless @page_dir + +- @files << @page_dir.to_s ++ @files << @page_dir + +- page_dir = nil ++ page_dir = Pathname(@page_dir) + begin +- page_dir = @page_dir.expand_path.relative_path_from @root ++ page_dir = page_dir.expand_path.relative_path_from @root + rescue ArgumentError + # On Windows, sometimes crosses different drive letters. +- page_dir = @page_dir.expand_path ++ page_dir = page_dir.expand_path + end + + @page_dir = page_dir +@@ -836,7 +846,7 @@ Usage: #{opt.program_name} [options] [names...] + "such files at your project root.", + "NOTE: Do not use the same file name in", + "the page dir and the root of your project") do |page_dir| +- @page_dir = Pathname(page_dir) ++ @page_dir = page_dir + end + + opt.separator nil +@@ -1148,13 +1158,6 @@ Usage: #{opt.program_name} [options] [names...] + + @files = argv.dup + +- finish +- +- if @write_options then +- write_options +- exit +- end +- + self + end + +@@ -1267,7 +1270,7 @@ Usage: #{opt.program_name} [options] [names...] + File.open '.rdoc_options', 'w' do |io| + io.set_encoding Encoding::UTF_8 + +- YAML.dump self, io ++ io.print to_yaml + end + end + +diff --git a/lib/rdoc/rdoc.rb b/lib/rdoc/rdoc.rb +index 5cf52ff..0716981 100644 +--- a/lib/rdoc/rdoc.rb ++++ b/lib/rdoc/rdoc.rb +@@ -464,11 +464,11 @@ The internal error was: + + if RDoc::Options === options then + @options = options +- @options.finish + else + @options = load_options + @options.parse options + end ++ @options.finish + + if @options.pipe then + handle_pipe +diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb +index 7f0e12f..4c7be3a 100644 +--- a/test/rdoc/test_rdoc_options.rb ++++ b/test/rdoc/test_rdoc_options.rb +@@ -55,11 +55,8 @@ class TestRDocOptions < RDoc::TestCase + refute @options.dry_run + end + +- def test_encode_with +- coder = {} +- class << coder; alias add []=; end +- +- @options.encode_with coder ++ def test_to_yaml ++ coder = YAML.load(@options.to_yaml) + + encoding = 'UTF-8' + +@@ -89,10 +86,9 @@ class TestRDocOptions < RDoc::TestCase + assert_equal expected, coder + end + +- def test_encode_with_trim_paths ++ def test_to_yaml_trim_paths + subdir = nil +- coder = {} +- class << coder; alias add []=; end ++ coder = nil + + temp_dir do |dir| + FileUtils.mkdir 'project' +@@ -113,7 +109,7 @@ class TestRDocOptions < RDoc::TestCase + --include / + ] + +- @options.encode_with coder ++ coder = YAML.load(@options.to_yaml) + end + end + +@@ -145,8 +141,10 @@ class TestRDocOptions < RDoc::TestCase + + @options.encoding = Encoding::IBM437 + +- options = YAML.safe_load(YAML.dump(@options), whitelist_classes=[RDoc::Options, Symbol]) +- ++ options = @options.to_yaml ++ options = YAML.safe_load(options, whitelist_classes=[Symbol]) ++ options = RDoc::Options.new(options) ++ + assert_equal Encoding::IBM437, options.encoding + end + +@@ -154,14 +152,15 @@ class TestRDocOptions < RDoc::TestCase + RDoc.load_yaml + + yaml = <<-YAML +---- !ruby/object:RDoc::Options ++--- + static_path: + - /etc + rdoc_include: + - /etc + YAML + +- options = YAML.safe_load(yaml, whitelist_classes=[RDoc::Options, Symbol]) ++ options = YAML.safe_load(yaml, whitelist_classes=[Symbol]) ++ options = RDoc::Options.new(options) + + assert_empty options.rdoc_include + assert_empty options.static_path +@@ -243,6 +242,7 @@ rdoc_include: + + def test_parse_default + @options.parse [] ++ @options.finish + + assert_equal RDoc::Generator::Darkfish, @options.generator + assert_equal 'darkfish', @options.template +@@ -488,6 +488,7 @@ rdoc_include: + + out, err = capture_io do + @options.parse %W[--page-dir #{Dir.tmpdir}] ++ @options.finish + end + + assert_empty out +@@ -516,6 +517,7 @@ rdoc_include: + + out, err = capture_io do + @options.parse %W[--page-dir #{abs_page_dir} --root #{abs_root}] ++ @options.finish + end + + assert_empty out +@@ -544,6 +546,8 @@ rdoc_include: + assert_empty err + + assert_equal Pathname(Dir.tmpdir), @options.root ++ ++ @options.finish + assert_includes @options.rdoc_include, @options.root.to_s + end + +@@ -588,6 +592,7 @@ rdoc_include: + assert_empty out + assert_equal "could not find template NONEXISTENT\n", err + ++ @options.finish + assert_equal 'darkfish', @options.template + assert_match %r%rdoc/generator/template/darkfish$%, @options.template_dir + end +@@ -639,6 +644,7 @@ rdoc_include: + Dir.chdir tmpdir do + e = assert_raises SystemExit do + @options.parse %w[--write-options] ++ @options.finish + end + + assert_equal 0, e.status +@@ -735,7 +741,9 @@ rdoc_include: + + assert File.exist? '.rdoc_options' + +- assert_equal @options, YAML.safe_load(File.read('.rdoc_options'), whitelist_classes=[RDoc::Options, Symbol]) ++ options = File.read('.rdoc_options') ++ options = YAML.safe_load(options, whitelist_classes=[Symbol]) ++ assert_equal @options, RDoc::Options.new(options) + end + end + +@@ -763,4 +771,10 @@ rdoc_include: + @options.visibility = :all + assert_equal :private, @options.visibility + end ++ ++ class DummyCoder < Hash ++ alias add :[]= ++ def tag=(tag) ++ end ++ end + end +diff --git a/test/rdoc/test_rdoc_rdoc.rb b/test/rdoc/test_rdoc_rdoc.rb +index 3516aa4..2cc815e 100644 +--- a/test/rdoc/test_rdoc_rdoc.rb ++++ b/test/rdoc/test_rdoc_rdoc.rb +@@ -131,12 +131,20 @@ class TestRDocRDoc < RDoc::TestCase + def test_load_options_partial_override + temp_dir do + File.open '.rdoc_options', 'w' do |io| +- io.write "markup: Markdown" ++ io.puts "markup: Markdown" ++ io.puts "encoding: iso-8859-1" ++ io.puts "static_path: [static]" ++ io.puts "rdoc_include: [.]" ++ io.puts "page_dir: pages" + end + + options = @rdoc.load_options + + assert_equal 'Markdown', options.markup ++ assert_equal Encoding::ISO_8859_1, options.encoding ++ assert_equal ["static"], options.static_path ++ assert_equal ["."], options.rdoc_include ++ assert_equal "pages", options.page_dir + end + end + +@@ -234,6 +242,7 @@ class TestRDocRDoc < RDoc::TestCase + top_level = nil + temp_dir do |dir| + @rdoc.options.parse %W[--root #{test_path}] ++ @rdoc.options.finish + + File.open 'include.txt', 'w' do |io| + io.puts ':include: test.txt' +-- +2.43.0 + diff --git a/backport-rdoc-Support-different-drive-latters-in-include-path.patch b/backport-rdoc-Support-different-drive-latters-in-include-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..828279b6a9621fec24f24fcff3146bdf80b65c12 --- /dev/null +++ b/backport-rdoc-Support-different-drive-latters-in-include-path.patch @@ -0,0 +1,75 @@ +From c8ce37d4271a58132fb7fc5548e0ba7d85419152 Mon Sep 17 00:00:00 2001 +From: aycabta +Date: Mon, 28 Oct 2019 01:44:09 +0900 +Subject: [PATCH] [ruby/rdoc] Support different drive latters in include paths + +https://github.com/ruby/rdoc/commit/946d2592e2 +https://github.com/ruby/ruby/commit/c8ce37d4271a58132fb7fc5548e0ba7d85419152 +--- + lib/rdoc/options.rb | 21 ++++++++++++++++++--- + test/rdoc/test_rdoc_options.rb | 10 ++++++++-- + 2 files changed, 26 insertions(+), 5 deletions(-) + +diff --git a/lib/rdoc/options.rb b/lib/rdoc/options.rb +index dc6a018..4e60540 100644 +--- a/lib/rdoc/options.rb ++++ b/lib/rdoc/options.rb +@@ -576,7 +576,13 @@ class RDoc::Options + + @files << @page_dir.to_s + +- page_dir = @page_dir.expand_path.relative_path_from @root ++ page_dir = nil ++ begin ++ page_dir = @page_dir.expand_path.relative_path_from @root ++ rescue ArgumentError ++ # On Windows, sometimes crosses different drive letters. ++ page_dir = @page_dir.expand_path ++ end + + @page_dir = page_dir + end +@@ -1175,8 +1181,17 @@ Usage: #{opt.program_name} [options] [names...] + + path.reject do |item| + path = Pathname.new(item).expand_path +- relative = path.relative_path_from(dot).to_s +- relative.start_with? '..' ++ is_reject = nil ++ relative = nil ++ begin ++ relative = path.relative_path_from(dot).to_s ++ rescue ArgumentError ++ # On Windows, sometimes crosses different drive letters. ++ is_reject = true ++ else ++ is_reject = relative.start_with? '..' ++ end ++ is_reject + end + end + +diff --git a/test/rdoc/test_rdoc_options.rb b/test/rdoc/test_rdoc_options.rb +index 55d1309..7f0e12f 100644 +--- a/test/rdoc/test_rdoc_options.rb ++++ b/test/rdoc/test_rdoc_options.rb +@@ -493,8 +493,14 @@ rdoc_include: + assert_empty out + assert_empty err + +- expected = +- Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root ++ expected = nil ++ begin ++ expected = ++ Pathname(Dir.tmpdir).expand_path.relative_path_from @options.root ++ rescue ArgumentError ++ # On Windows, sometimes crosses different drive letters. ++ expected = Pathname(Dir.tmpdir).expand_path ++ end + + assert_equal expected, @options.page_dir + assert_equal [Dir.tmpdir], @options.files +-- +2.43.0 + diff --git a/ruby.spec b/ruby.spec index a1cbe22fad79071446e5c8c11e19b800f02896eb..a614a788a58f54c8b4e23a775d731b227d8c65f0 100644 --- a/ruby.spec +++ b/ruby.spec @@ -1,6 +1,6 @@ Name: ruby Version: 2.5.8 -Release: 124 +Release: 125 Summary: Object-oriented scripting language interpreter License: (Ruby or BSD) and Public Domain and MIT and CC0 and zlib and UCD URL: https://www.ruby-lang.org/ @@ -62,6 +62,9 @@ Patch6018: backport-CVE-2024-27281-Use-safe_load-for-.rdoc_options.patch Patch6019: backport-CVE-2024-27281-Fix-NoMethodError-for-start_with.patch Patch6020: backport-Use-File.open-instead-of-Kernel-open.patch Patch6021: backport-CVE-2024-27282.patch +Patch6022: backport-rdoc-Allow-partial-default-values-to-be-overridden.patch +Patch6023: backport-rdoc-Support-different-drive-latters-in-include-path.patch +Patch6024: backport-rdoc-Dump-plain-objects-as-RDoc-Options.patch Provides: %{name}-libs = %{version}-%{release} Obsoletes: %{name}-libs < %{version}-%{release} @@ -599,6 +602,9 @@ make runruby TESTRUN_SCRIPT=%{SOURCE13} %exclude %{gem_dir}/gems/xmlrpc-0.3.0/.* %changelog +* Mon May 27 2024 shixuantong - 2.5.8-125 +- Dump plain objects as RDoc::Options so that the generated .rdoc_options file is loadable + * Mon May 6 2024 zhoupengcheng11 - 2.5.8-124 - fix CVE-2024-27282