Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge RDoc-6.4.1.1 for Ruby 3.1 #10318

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 26 additions & 19 deletions lib/rdoc/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/rdoc/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module RDoc
##
# RDoc version you are using

VERSION = '6.4.0'
VERSION = '6.4.1.1'

end