diff options
Diffstat (limited to 'lib/rubygems/core_ext/kernel_require.rb')
-rw-r--r-- | lib/rubygems/core_ext/kernel_require.rb | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/lib/rubygems/core_ext/kernel_require.rb b/lib/rubygems/core_ext/kernel_require.rb index 60f4d18712..a8d170f13a 100644 --- a/lib/rubygems/core_ext/kernel_require.rb +++ b/lib/rubygems/core_ext/kernel_require.rb @@ -43,18 +43,21 @@ module Kernel # https://github.com/rubygems/rubygems/pull/1868 resolved_path = begin rp = nil - $LOAD_PATH[0...Gem.load_path_insert_index || -1].each do |lp| - safe_lp = lp.dup.tap(&Gem::UNTAINT) - begin - if File.symlink? safe_lp # for backward compatibility - next + Gem.suffixes.each do |s| + load_path_insert_index = Gem.load_path_insert_index + break unless load_path_insert_index + + $LOAD_PATH[0...load_path_insert_index].each do |lp| + safe_lp = lp.dup.tap(&Gem::UNTAINT) + begin + if File.symlink? safe_lp # for backward compatibility + next + end + rescue SecurityError + RUBYGEMS_ACTIVATION_MONITOR.exit + raise end - rescue SecurityError - RUBYGEMS_ACTIVATION_MONITOR.exit - raise - end - Gem.suffixes.each do |s| full_path = File.expand_path(File.join(safe_lp, "#{path}#{s}")) if File.file?(full_path) rp = full_path @@ -67,12 +70,8 @@ module Kernel end if resolved_path - begin - RUBYGEMS_ACTIVATION_MONITOR.exit - return gem_original_require(resolved_path) - rescue LoadError - RUBYGEMS_ACTIVATION_MONITOR.enter - end + RUBYGEMS_ACTIVATION_MONITOR.exit + return gem_original_require(resolved_path) end if spec = Gem.find_unresolved_default_spec(path) |