Procházet zdrojové kódy

Fix installation failing when Redis password contains special characters (#13156)

* Add support for special characters in Redis passwords

Fixes #13154

* Refactor
master^2
ThibG před 4 roky
committed by GitHub
rodič
revize
ce17cea221
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: 4AEE18F83AFDEB23
2 změnil soubory, kde provedl 17 přidání a 2 odebrání
  1. +3
    -1
      lib/mastodon/redis_config.rb
  2. +14
    -1
      lib/tasks/mastodon.rake

+ 3
- 1
lib/mastodon/redis_config.rb Zobrazit soubor

@@ -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



+ 14
- 1
lib/tasks/mastodon.rake Zobrazit soubor

@@ -336,7 +336,20 @@ namespace :mastodon do
if prompt.yes?('Save configuration?')
cmd = TTY::Command.new(printer: :quiet)

File.write(Rails.root.join('.env.production'), "# Generated with mastodon:setup on #{Time.now.utc}\n\n" + env.each_pair.map { |key, value| "#{key}=#{value}" }.join("\n") + "\n")
env_contents = env.each_pair.map do |key, value|
if value.is_a?(String) && value =~ /[\s\#\\"]/
if value =~ /[']/
value = value.to_s.gsub(/[\\"\$]/) { |x| "\\#{x}" }
"#{key}=\"#{value}\""
else
"#{key}='#{value}'"
end
else
"#{key}=#{value}"
end
end.join("\n")

File.write(Rails.root.join('.env.production'), "# Generated with mastodon:setup on #{Time.now.utc}\n\n" + env_contents + "\n")

if using_docker
prompt.ok 'Below is your configuration, save it to an .env.production file outside Docker:'


Načítá se…
Zrušit
Uložit