From 1254b0066f312ddbf7fae7a195e66ce5b3bc6656 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 20 Feb 2024 17:30:25 +0900 Subject: [PATCH 1/4] Filter marshaled objects --- lib/rdoc/store.rb | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index 5ba671ca1b..5b663d73fb 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -556,9 +556,7 @@ def load_all def load_cache #orig_enc = @encoding - File.open cache_path, 'rb' do |io| - @cache = Marshal.load io.read - end + @cache = marshal_load(cache_path) load_enc = @cache[:encoding] @@ -615,9 +613,7 @@ def load_class klass_name def load_class_data klass_name file = class_file klass_name - File.open file, 'rb' do |io| - Marshal.load io.read - end + marshal_load(file) rescue Errno::ENOENT => e error = MissingFileError.new(self, file, klass_name) error.set_backtrace e.backtrace @@ -630,14 +626,10 @@ def load_class_data klass_name def load_method klass_name, method_name file = method_file klass_name, method_name - File.open file, 'rb' do |io| - obj = Marshal.load io.read - obj.store = self - obj.parent = - find_class_or_module(klass_name) || load_class(klass_name) unless - obj.parent - obj - end + obj = marshal_load(file) + obj.store = self + obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name) + obj rescue Errno::ENOENT => e error = MissingFileError.new(self, file, klass_name + method_name) error.set_backtrace e.backtrace @@ -650,11 +642,9 @@ def load_method klass_name, method_name def load_page page_name file = page_file page_name - File.open file, 'rb' do |io| - obj = Marshal.load io.read - obj.store = self - obj - end + obj = marshal_load(file) + obj.store = self + obj rescue Errno::ENOENT => e error = MissingFileError.new(self, file, page_name) error.set_backtrace e.backtrace @@ -976,4 +966,21 @@ def unique_modules @unique_modules end + private + def marshal_load(file) + File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)} + end + + MarshalFilter = proc do |obj| + case obj + when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text + else + unless obj.class.name.start_with("RDoc::") + raise TypeError, "not permitted class: #{obj.class.name}" + end + end + obj + end + private_constant :MarshalFilter + end From 728073cab5350035cba36ccaab359c2a4212c81a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 19 Mar 2024 22:10:42 +0900 Subject: [PATCH 2/4] Bump up 6.4.1 --- lib/rdoc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb index 86c5b360fd..bc881a995f 100644 --- a/lib/rdoc/version.rb +++ b/lib/rdoc/version.rb @@ -3,6 +3,6 @@ module RDoc ## # RDoc version you are using - VERSION = '6.4.0' + VERSION = '6.4.1' end From 48617985e9fbc2825219d55f04e3e0e98d2923be Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 21 Mar 2024 13:18:13 +0900 Subject: [PATCH 3/4] Fix NoMethodError for start_with --- lib/rdoc/store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/store.rb b/lib/rdoc/store.rb index 5b663d73fb..c793e49ed8 100644 --- a/lib/rdoc/store.rb +++ b/lib/rdoc/store.rb @@ -975,7 +975,7 @@ def marshal_load(file) case obj when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text else - unless obj.class.name.start_with("RDoc::") + unless obj.class.name.start_with?("RDoc::") raise TypeError, "not permitted class: #{obj.class.name}" end end From 5a9cc4a9254cc02e1705579ebc5aeca32d6e26ac Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Thu, 21 Mar 2024 13:23:19 +0900 Subject: [PATCH 4/4] Bump up 6.4.1.1 --- lib/rdoc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rdoc/version.rb b/lib/rdoc/version.rb index bc881a995f..c3ff6640f5 100644 --- a/lib/rdoc/version.rb +++ b/lib/rdoc/version.rb @@ -3,6 +3,6 @@ module RDoc ## # RDoc version you are using - VERSION = '6.4.1' + VERSION = '6.4.1.1' end