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 Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
||||||
class BuilderError < StandardError; end
|
class BuilderError < StandardError; end
|
||||||
|
|
||||||
@@ -44,7 +46,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def build_context
|
def build_context
|
||||||
config.builder.context
|
Shellwords.escape(config.builder.context)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_image
|
def validate_image
|
||||||
@@ -92,7 +94,7 @@ class Kamal::Commands::Builder::Base < Kamal::Commands::Base
|
|||||||
|
|
||||||
def build_dockerfile
|
def build_dockerfile
|
||||||
if Pathname.new(File.expand_path(dockerfile)).exist?
|
if Pathname.new(File.expand_path(dockerfile)).exist?
|
||||||
argumentize "--file", dockerfile
|
argumentize "--file", Shellwords.escape(dockerfile)
|
||||||
else
|
else
|
||||||
raise BuilderError, "Missing #{dockerfile}"
|
raise BuilderError, "Missing #{dockerfile}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
require "tempfile"
|
require "tempfile"
|
||||||
require "open3"
|
require "open3"
|
||||||
|
require "shellwords"
|
||||||
|
|
||||||
module Kamal::Docker
|
module Kamal::Docker
|
||||||
extend self
|
extend self
|
||||||
@@ -15,7 +16,7 @@ module Kamal::Docker
|
|||||||
DOCKERFILE
|
DOCKERFILE
|
||||||
dockerfile.close
|
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")
|
system(cmd) || raise("failed to build check image")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user