about summary refs log tree commit diff
path: root/lib/mastodon/redis_config.rb
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-02-29 03:00:43 +0100
committerGitHub <noreply@github.com>2020-02-29 03:00:43 +0100
commitce17cea2210f9ce9dcbaf68074c07633df61bb6f (patch)
tree707850e10f9da776a7061c4c73948da47327d3ea /lib/mastodon/redis_config.rb
parent047fde18c3d20dcd74b14613a648a03b573f802d (diff)
Fix installation failing when Redis password contains special characters (#13156)
* Add support for special characters in Redis passwords

Fixes #13154

* Refactor
Diffstat (limited to 'lib/mastodon/redis_config.rb')
-rw-r--r--lib/mastodon/redis_config.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb
index f11d94a45..e9db9122f 100644
--- a/lib/mastodon/redis_config.rb
+++ b/lib/mastodon/redis_config.rb
@@ -14,7 +14,9 @@ def setup_redis_env_url(prefix = nil, defaults = true)
   ENV[prefix + 'REDIS_URL'] = if [password, host, port, db].all?(&:nil?)
                                 ENV['REDIS_URL']
                               else
-                                "redis://#{password.blank? ? '' : ":#{password}@"}#{host}:#{port}/#{db}"
+                                Addressable::URI.parse("redis://#{host}:#{port}/#{db}").tap do |uri|
+                                  uri.password = password if password.present?
+                                end.normalize.to_str
                               end
 end