Merge pull request #6260 from samphippen/samphippen/bugfix/6065
Samphippen/bugfix/6065
This commit is contained in:
commit
b79f0bb7a9
|
@ -182,7 +182,11 @@ module VagrantPlugins
|
|||
# Replace Windows line endings with Unix ones unless binary file
|
||||
# or we're running on Windows.
|
||||
if !config.binary && @machine.config.vm.communicator != :winrm
|
||||
script.gsub!(/\r\n?$/, "\n")
|
||||
begin
|
||||
script.gsub!(/\r\n?$/, "\n")
|
||||
rescue ArgumentError
|
||||
script = script.force_encoding("ASCII-8BIT").gsub(/\r\n?$/, "\n")
|
||||
end
|
||||
end
|
||||
|
||||
# Otherwise we have an inline script, we need to Tempfile it,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
require File.expand_path("../../../../base", __FILE__)
|
||||
require Vagrant.source_root.join("plugins/provisioners/shell/provisioner")
|
||||
|
||||
describe "Vagrant::Shell::Provisioner" do
|
||||
|
||||
let(:machine) {
|
||||
double(:machine).tap { |machine|
|
||||
machine.stub_chain(:config, :vm, :communicator).and_return(:not_winrm)
|
||||
machine.stub_chain(:communicate, :tap) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
context "with a script that contains invalid us-ascii byte sequences" do
|
||||
let(:config) {
|
||||
double(
|
||||
:config,
|
||||
:args => "doesn't matter",
|
||||
:upload_path => "arbitrary",
|
||||
:remote? => false,
|
||||
:path => nil,
|
||||
:inline => script_that_is_incorrectly_us_ascii_encoded,
|
||||
:binary => false,
|
||||
)
|
||||
}
|
||||
|
||||
let(:script_that_is_incorrectly_us_ascii_encoded) {
|
||||
[207].pack("c*").force_encoding("US-ASCII")
|
||||
}
|
||||
|
||||
it "does not raise an exception when normalizing newlines" do
|
||||
vsp = VagrantPlugins::Shell::Provisioner.new(machine, config)
|
||||
|
||||
expect {
|
||||
vsp.provision
|
||||
}.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue