Coder Social home page Coder Social logo

non-ASCII in env file about kamal HOT 3 CLOSED

zhongsheng avatar zhongsheng commented on August 29, 2024
non-ASCII in env file

from kamal.

Comments (3)

xiaohui-zhangxh avatar xiaohui-zhangxh commented on August 29, 2024

I found this bug since mrsk was issued, Shellescape can fix this #750

from kamal.

xiaohui-zhangxh avatar xiaohui-zhangxh commented on August 29, 2024

I found this bug since mrsk was issued, Shellescape can fix this #750

This is not a good fix, also makes some other problems. I will try to fix it in another way

from kamal.

xiaohui-zhangxh avatar xiaohui-zhangxh commented on August 29, 2024

Here the PR can fix this issue.

Copy below patch to /tmp/kamal.patch, then run this to fix temporarily.

cd /usr/local/bundle/gems/kamal-1.4.0/ && patch -p1 -i /tmp/kamal.patch
diff --git a/lib/kamal/env_file.rb b/lib/kamal/env_file.rb
index 0c9f234..2228be0 100644
--- a/lib/kamal/env_file.rb
+++ b/lib/kamal/env_file.rb
@@ -24,6 +24,13 @@ class Kamal::EnvFile

     # Escape a value to make it safe to dump in a docker file.
     def escape_docker_env_file_value(value)
+      # keep non-ascii(UTF-8) characters as it is
+      value.to_s.scan(/[\x00-\x7F]+|[^\x00-\x7F]+/).map do |part|
+        part.ascii_only? ? escape_docker_env_file_ascii_value(part) : part
+      end.join
+    end
+
+    def escape_docker_env_file_ascii_value(value)
       # Doublequotes are treated literally in docker env files
       # so remove leading and trailing ones and unescape any others
       value.to_s.dump[1..-2].gsub(/\\"/, "\"")

from kamal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.