prevent escape '#' when generating env_file string
This commit is contained in:
@@ -37,6 +37,8 @@ class Kamal::EnvFile
|
|||||||
def escape_docker_env_file_ascii_value(value)
|
def escape_docker_env_file_ascii_value(value)
|
||||||
# Doublequotes are treated literally in docker env files
|
# Doublequotes are treated literally in docker env files
|
||||||
# so remove leading and trailing ones and unescape any others
|
# so remove leading and trailing ones and unescape any others
|
||||||
value.to_s.dump[1..-2].gsub(/\\"/, "\"")
|
value.to_s.dump[1..-2]
|
||||||
|
.gsub(/\\"/, "\"")
|
||||||
|
.gsub(/\\#/, "#")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -11,6 +11,16 @@ class EnvFileTest < ActiveSupport::TestCase
|
|||||||
Kamal::EnvFile.new(env).to_s
|
Kamal::EnvFile.new(env).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "to_s won't escape '#'" do
|
||||||
|
env = {
|
||||||
|
"foo" => "\#$foo",
|
||||||
|
"bar" => "\#{bar}"
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_equal "foo=\#$foo\nbar=\#{bar}\n", \
|
||||||
|
Kamal::EnvFile.new(env).to_s
|
||||||
|
end
|
||||||
|
|
||||||
test "to_str won't escape chinese characters" do
|
test "to_str won't escape chinese characters" do
|
||||||
env = {
|
env = {
|
||||||
"foo" => '你好 means hello, "欢迎" means welcome, that\'s simple! 😃 {smile}'
|
"foo" => '你好 means hello, "欢迎" means welcome, that\'s simple! 😃 {smile}'
|
||||||
|
|||||||
Reference in New Issue
Block a user