Ignore URLs which cannot be parsed in the authentication middleware
Fixes #9725
This commit is contained in:
parent
a26d861ae6
commit
97f5822dee
|
@ -35,6 +35,7 @@ module VagrantPlugins
|
||||||
token = client.token
|
token = client.token
|
||||||
|
|
||||||
env[:box_urls].map! do |url|
|
env[:box_urls].map! do |url|
|
||||||
|
begin
|
||||||
u = URI.parse(url)
|
u = URI.parse(url)
|
||||||
if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host)
|
if u.host != TARGET_HOST && REPLACEMENT_HOSTS.include?(u.host)
|
||||||
u.host = TARGET_HOST
|
u.host = TARGET_HOST
|
||||||
|
@ -42,6 +43,9 @@ module VagrantPlugins
|
||||||
else
|
else
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
rescue URI::Error
|
||||||
|
url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
server_uri = URI.parse(Vagrant.server_url.to_s)
|
server_uri = URI.parse(Vagrant.server_url.to_s)
|
||||||
|
|
|
@ -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