Ignore URLs which cannot be parsed in the authentication middleware
Fixes #9725
This commit is contained in:
parent
a26d861ae6
commit
97f5822dee
|
@ -35,11 +35,15 @@ module VagrantPlugins
|
||||||
token = client.token
|
token = client.token
|
||||||
|
|
||||||
env[:box_urls].map! do |url|
|
env[:box_urls].map! do |url|
|
||||||
u = URI.parse(url)
|
begin
|
||||||
if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host)
|
u = URI.parse(url)
|
||||||
u.host = TARGET_HOST
|
if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host)
|
||||||
u.to_s
|
u.host = TARGET_HOST
|
||||||
else
|
u.to_s
|
||||||
|
else
|
||||||
|
url
|
||||||
|
end
|
||||||
|
rescue URI::Error
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -125,6 +125,15 @@ describe VagrantPlugins::LoginCommand::AddAuthentication do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "ignores urls that it cannot parse" do
|
||||||
|
bad_url = "this is not a valid url"
|
||||||
|
# Ensure the bad URL does cause an exception
|
||||||
|
expect{ URI.parse(bad_url) }.to raise_error URI::Error
|
||||||
|
env[:box_urls] = [bad_url]
|
||||||
|
subject.call(env)
|
||||||
|
expect(env[:box_urls].first).to eq(bad_url)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns original urls when not modified" do
|
it "returns original urls when not modified" do
|
||||||
to_persist = "file:////path/to/box.box"
|
to_persist = "file:////path/to/box.box"
|
||||||
to_change = VagrantPlugins::LoginCommand::AddAuthentication::
|
to_change = VagrantPlugins::LoginCommand::AddAuthentication::
|
||||||
|
|
Loading…
Reference in New Issue