diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb index 0dc868b..4776a6c 100644 --- a/lib/vagrant-libvirt/config.rb +++ b/lib/vagrant-libvirt/config.rb @@ -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') diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 989d044..147ca20 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -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'},