summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-02-16 22:24:53 -0500
committerJames Wen <jrw2175@columbia.edu>2016-02-16 23:03:44 -0500
commit0611c4bea9a5da42f668af64ae31d7628c640c5e (patch)
tree5fa0dbefdba57642e0342f15f22742b664b8190d
parent73e23068114da3cbb110a9a8c1aed4cd03b1a0f8 (diff)
downloadbundler-0611c4bea9a5da42f668af64ae31d7628c640c5e.tar.gz
Add helpful message and error handling for non-CGI-escaped authentication
- Closes #4288
-rw-r--r--lib/bundler/source/rubygems/remote.rb4
-rw-r--r--spec/commands/install_spec.rb16
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/bundler/source/rubygems/remote.rb b/lib/bundler/source/rubygems/remote.rb
index 32265fb600..92f8a40588 100644
--- a/lib/bundler/source/rubygems/remote.rb
+++ b/lib/bundler/source/rubygems/remote.rb
@@ -39,6 +39,10 @@ module Bundler
end
uri
+ rescue URI::InvalidComponentError
+ error_message = "Please CGI escape your usernames and passwords before " \
+ "setting them for authentication."
+ raise HTTPError.new(error_message)
end
def remove_auth(uri)
diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb
index 9c81457068..e48d5009ae 100644
--- a/spec/commands/install_spec.rb
+++ b/spec/commands/install_spec.rb
@@ -459,4 +459,20 @@ describe "bundle install with gem sources" do
expect(out).to include("grant write permissions")
end
end
+
+ describe "when bundle install is executed with unencoded authentication" do
+ before do
+ gemfile <<-G
+ source 'https://rubygems.org/'
+ gem 'bundler'
+ G
+ end
+
+ it "should display a helpful messag explaining how to fix it" do
+ bundle :install, :env => { "BUNDLE_RUBYGEMS__ORG" => "user:pass{word" }
+ expect(exitstatus).to eq(17) if exitstatus
+ expect(out).to eq("Please CGI escape your usernames and passwords before " \
+ "setting them for authentication.")
+ end
+ end
end