Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions bundler/lib/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -641,12 +641,11 @@ def reset_rubygems!
private

def eval_yaml_gemspec(path, contents)
require_relative "bundler/psyched_yaml"
Kernel.send(:require, "yaml")

# If the YAML is invalid, Syck raises an ArgumentError, and Psych
# raises a Psych::SyntaxError. See psyched_yaml.rb for more info.
# If the YAML is invalid, Psych raises a Psych::SyntaxError.
Gem::Specification.from_yaml(contents)
rescue YamlLibrarySyntaxError, ArgumentError, Gem::EndOfYAMLException, Gem::Exception
rescue Psych::SyntaxError, Gem::EndOfYAMLException, Gem::Exception
eval_gemspec(path, contents)
end

Expand Down
8 changes: 4 additions & 4 deletions bundler/lib/bundler/plugin/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ def load_index(index_file, global = false)

data = index_f.read

require_relative "../yaml_serializer"
index = YAMLSerializer.load(data)
require "yaml"
index = YAML.load(data)

@commands.merge!(index["commands"])
@hooks.merge!(index["hooks"])
Expand All @@ -171,10 +171,10 @@ def save_index
"sources" => @sources,
}

require_relative "../yaml_serializer"
require "yaml"
SharedHelpers.filesystem_access(index_file) do |index_f|
FileUtils.mkdir_p(index_f.dirname)
File.open(index_f, "w") {|f| f.puts YAMLSerializer.dump(index) }
File.open(index_f, "w") {|f| f.puts YAML.dump(index) }
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions bundler/lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def platforms
end

def configuration
require_relative "psyched_yaml"
require "yaml"
Gem.configuration
rescue Gem::SystemExitException, LoadError => e
Bundler.ui.error "#{e.class}: #{e.message}"
Expand Down Expand Up @@ -253,7 +253,7 @@ def with_build_args(args)

def spec_from_gem(path, policy = nil)
require "rubygems/security"
require_relative "psyched_yaml"
require "yaml"
gem_from_path(path, security_policies[policy]).spec
rescue Exception, Gem::Exception, Gem::Security::Exception => e # rubocop:disable Lint/RescueException
if e.is_a?(Gem::Security::Exception) ||
Expand Down
19 changes: 8 additions & 11 deletions bundler/lib/bundler/settings.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require "uri"

module Bundler
class Settings
autoload :Mirror, File.expand_path("mirror", __dir__)
Expand Down Expand Up @@ -139,11 +141,7 @@ def local_overrides
end

def mirror_for(uri)
if uri.is_a?(String)
require_relative "vendored_uri"
uri = Bundler::URI(uri)
end

uri = URI(uri.to_s) unless uri.is_a?(URI)
gem_mirrors.for(uri.to_s).uri
end

Expand Down Expand Up @@ -358,8 +356,8 @@ def set_key(raw_key, value, hash, file)
return unless file
SharedHelpers.filesystem_access(file) do |p|
FileUtils.mkdir_p(p.dirname)
require_relative "yaml_serializer"
p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
require "yaml"
p.open("w") {|f| f.write(YAML.dump(hash)) }
end
end

Expand Down Expand Up @@ -398,8 +396,8 @@ def load_config(config_file)
SharedHelpers.filesystem_access(config_file, :read) do |file|
valid_file = file.exist? && !file.size.zero?
return {} unless valid_file
require_relative "yaml_serializer"
YAMLSerializer.load file.read
require "yaml"
YAML.load file.read
end
end

Expand All @@ -426,8 +424,7 @@ def self.normalize_uri(uri)
suffix = $3
end
uri = "#{uri}/" unless uri.end_with?("/")
require_relative "vendored_uri"
uri = Bundler::URI(uri)
uri = URI(uri)
unless uri.absolute?
raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
end
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/bundler/bundler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
context "with Psych as YAML::Engine" do
it "raises a GemspecError after YAML load throws Psych::SyntaxError" do
orig_yamler = YAML::ENGINE.yamler
YAML::ENGINE.yamler = "psych"
YAML::ENGINE.yamler = "yaml"

expect { subject }.to raise_error(Bundler::GemspecError)

Expand Down
9 changes: 0 additions & 9 deletions bundler/spec/bundler/psyched_yaml_spec.rb

This file was deleted.

2 changes: 1 addition & 1 deletion bundler/spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

require "bundler/psyched_yaml"
require "yaml"
require "bundler/vendored_fileutils"
require "bundler/vendored_uri"
require "digest"
Expand Down