Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,22 @@
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false

config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = {
host: ENV["MAIL_LINK_HOST"],
protocol: ENV["MAIL_LINK_PROTO"] || "https"
}

smtp_env = Hash[ENV.map do |k, v|
if /^SMTP_(.*)$/ === k
[$1.downcase.to_sym, YAML.load(v)]
end
end.compact]
smtp_env = ENV.filter { |k, _| k.start_with?("SMTP_") }
.to_h { |k, v| [k.delete_prefix("SMTP_").downcase.to_sym, YAML.load(v)] }
Comment on lines +90 to +91
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YAML.load(v) will deserialize arbitrary YAML from environment variables, which can instantiate unexpected Ruby objects and is generally unsafe. Prefer YAML.safe_load (permitting only basic scalar types you expect) or explicit casting (e.g., int/bool parsing) for SMTP settings values.

Copilot uses AI. Check for mistakes.


if smtp_env.present?
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = smtp_env
else
config.action_mailer.delivery_method = :test
config.action_mailer.perform_deliveries = false
warn "[TimeOverflow] No SMTP configuration found (SMTP_* env vars). Email delivery is disabled."
end

# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
Expand Down
Loading