Rebuild command and arguments before exec on Windows

Flat command can cause issues with arguments. Creating new
string instances from arguments forces common encoding of
all strings used for exec.

Fixes #8690
This commit is contained in:
Chris Roberts 2017-06-21 07:03:15 -07:00
parent c5db5ea1c8
commit f3daf5fad7
1 changed files with 4 additions and 7 deletions

View File

@ -41,14 +41,11 @@ module Vagrant
end end
else else
if Vagrant::Util::Platform.windows? if Vagrant::Util::Platform.windows?
@@logger.debug("Converting command and arguments to single string for exec") # Re-generate strings to ensure common encoding
@@logger.debug("Command: `#{command.inspect}` Args: `#{args.inspect}`") command = "#{command}".force_encoding("UTF-8")
full_command = "#{command} #{args.join(" ")}" args = args.map{|arg| "#{arg}".force_encoding("UTF-8") }
@@logger.debug("Converted command: #{full_command}")
Kernel.exec(full_command)
else
Kernel.exec(command, *args)
end end
Kernel.exec(command, *args)
end end
rescue *rescue_from rescue *rescue_from
# We retried already, raise the issue and be done # We retried already, raise the issue and be done