diff --git a/Gemfile.lock b/Gemfile.lock index c33b4fb8906..c372f410723 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -202,14 +202,14 @@ GEM dotenv (= 2.7.5) railties (>= 3.2, < 6.1) e2mmap (0.1.0) - elasticsearch (7.3.0) - elasticsearch-api (= 7.3.0) - elasticsearch-transport (= 7.3.0) - elasticsearch-api (7.3.0) + elasticsearch (7.5.0) + elasticsearch-api (= 7.5.0) + elasticsearch-transport (= 7.5.0) + elasticsearch-api (7.5.0) multi_json elasticsearch-dsl (0.1.8) - elasticsearch-transport (7.3.0) - faraday + elasticsearch-transport (7.5.0) + faraday (>= 0.14, < 1) multi_json encryptor (3.0.0) equatable (0.6.1) @@ -220,7 +220,7 @@ GEM fabrication (2.21.0) faker (2.10.1) i18n (>= 1.6, < 2) - faraday (1.0.0) + faraday (0.17.3) multipart-post (>= 1.2, < 3) fast_blank (1.0.0) fastimage (2.1.7) @@ -437,7 +437,7 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.3) - puma (4.3.1) + puma (4.3.2) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) diff --git a/app/models/account.rb b/app/models/account.rb index e468884156d..0fcf897c918 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -480,7 +480,16 @@ class Account < ApplicationRecord def from_text(text) return [] if text.blank? - text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map { |(username, domain)| EntityCache.instance.mention(username, domain) } + text.scan(MENTION_RE).map { |match| match.first.split('@', 2) }.uniq.map do |(username, domain)| + domain = begin + if TagManager.instance.local_domain?(domain) + nil + else + TagManager.instance.normalize_domain(domain) + end + end + EntityCache.instance.mention(username, domain) + end.compact end private diff --git a/lib/mastodon/redis_config.rb b/lib/mastodon/redis_config.rb index f11d94a45e8..e9db9122fab 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 diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 2e92e8dedbe..a873335d405 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -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:'