Fix trailing quotes in source path
This commit is contained in:
parent
904a712838
commit
412290828b
|
@ -52,6 +52,11 @@ module VagrantPlugins
|
||||||
raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp
|
raise Vagrant::Errors::CLIInvalidUsage, help: opts.help.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# NOTE: We do this to handle paths on Windows like: "..\space dir\"
|
||||||
|
# because the final separater acts to escape the quote and ends up
|
||||||
|
# in the source value.
|
||||||
|
source = source.sub(/["']$/, "")
|
||||||
|
|
||||||
if File.file?(source)
|
if File.file?(source)
|
||||||
type = :file
|
type = :file
|
||||||
elsif File.directory?(source)
|
elsif File.directory?(source)
|
||||||
|
|
|
@ -101,6 +101,24 @@ describe VagrantPlugins::CommandUpload::Command do
|
||||||
expect { subject.execute }.to raise_error(Vagrant::Errors::UploadSourceMissing)
|
expect { subject.execute }.to raise_error(Vagrant::Errors::UploadSourceMissing)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when source path ends with double quote" do
|
||||||
|
let(:argv) { [".\\item\""] }
|
||||||
|
|
||||||
|
it "should remove trailing quote" do
|
||||||
|
expect(File).to receive(:file?).with(".\\item").and_return(true)
|
||||||
|
subject.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when source path ends with single quote" do
|
||||||
|
let(:argv) { ['.\item\''] }
|
||||||
|
|
||||||
|
it "should remove trailing quote" do
|
||||||
|
expect(File).to receive(:file?).with(".\\item").and_return(true)
|
||||||
|
subject.execute
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when source is a directory" do
|
context "when source is a directory" do
|
||||||
before do
|
before do
|
||||||
allow(File).to receive(:file?).with("item").and_return(false)
|
allow(File).to receive(:file?).with("item").and_return(false)
|
||||||
|
|
Loading…
Reference in New Issue