Escape strings for the shell
Whitespaces in strings were interpreted by the shell as new words. Escaping them ensures the shell sees the string as a single value.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
require "shellwords"
|
||||
|
||||
class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
||||
class BuilderError < StandardError; end
|
||||
|
||||
@@ -44,7 +46,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
def build_context
|
||||
config.builder.context
|
||||
Shellwords.escape(config.builder.context)
|
||||
end
|
||||
|
||||
def validate_image
|
||||
@@ -92,7 +94,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
||||
|
||||
def build_dockerfile
|
||||
if Pathname.new(File.expand_path(dockerfile)).exist?
|
||||
argumentize "--file", dockerfile
|
||||
argumentize "--file", Shellwords.escape(dockerfile)
|
||||
else
|
||||
raise BuilderError, "Missing #{dockerfile}"
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
require "tempfile"
|
||||
require "open3"
|
||||
require "shellwords"
|
||||
|
||||
module Kamal::Docker
|
||||
extend self
|
||||
@@ -15,7 +16,7 @@ module Kamal::Docker
|
||||
DOCKERFILE
|
||||
dockerfile.close
|
||||
|
||||
cmd = "docker buildx build -t=#{BUILD_CHECK_TAG} -f=#{dockerfile.path} ."
|
||||
cmd = "docker buildx build -t=#{BUILD_CHECK_TAG} -f=#{Shellwords.escape(dockerfile.path)} ."
|
||||
system(cmd) || raise("failed to build check image")
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user