Ensure usernames with at symbols handled (#1558)

Domain usernames may use '@' as part of the username, which requires
encoding to be able to be used within an URI.
This commit is contained in:
Darragh Bailey
2022-08-24 18:16:14 +01:00
committed by GitHub
parent 1945754f67
commit 8673fa2791
2 changed files with 8 additions and 1 deletions

View File

@@ -782,7 +782,7 @@ module VagrantPlugins
finalize_id_ssh_key_file
uri += '+ssh://'
uri += "#{@username}@" if @username && @username != UNSET_VALUE
uri += "#{URI.encode_www_form_component(@username)}@" if @username && @username != UNSET_VALUE
uri += (@host && @host != UNSET_VALUE ? @host : 'localhost')

View File

@@ -197,6 +197,13 @@ describe VagrantPlugins::ProviderLibvirt::Config do
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
}
],
[ # when username explicitly set with @ symbol for domains
{:username => 'my_user@my_domain', :host => 'remote'},
{:uri => %r{qemu://remote/(system|session)}, :username => 'my_user@my_domain'},
{
:env => {'LIBVIRT_DEFAULT_URI' => 'qemu:///custom'},
}
],
[ # when username explicitly set with host but without ssh
{:username => 'my_user', :host => 'remote'},
{:uri => %r{qemu://remote/(system|session)}, :username => 'my_user'},