From 96f246e3cb6e147443f63234d671a27f66dee4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Mon, 18 Jul 2022 13:19:55 +0200 Subject: [PATCH] Properly cast booleans from ENV input https://community.openproject.org/wp/43237 --- lib/tasks/email.rake | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 8d21f519d2..9c8e26799d 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -137,15 +137,17 @@ namespace :redmine do END_DESC task receive_imap: :environment do - imap_options = { host: ENV.fetch('host', nil), - port: ENV.fetch('port', nil), - ssl: ENV.fetch('ssl', nil), - ssl_verification: !['0', 'false', 'f'].include?(ENV.fetch('ssl_verification', nil)), - username: ENV.fetch('username', nil), - password: ENV.fetch('password', nil), - folder: ENV.fetch('folder', nil), - move_on_success: ENV.fetch('move_on_success', nil), - move_on_failure: ENV.fetch('move_on_failure', nil) } + imap_options = { + host: ENV.fetch('host', nil), + port: ENV.fetch('port', nil), + ssl: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('ssl', true)), + ssl_verification: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('ssl_verification', true)), + username: ENV.fetch('username', nil), + password: ENV.fetch('password', nil), + folder: ENV.fetch('folder', nil), + move_on_success: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('move_on_success', nil)), + move_on_failure: ActiveRecord::Type::Boolean.new.cast(ENV.fetch('move_on_failure', nil)) + } Redmine::IMAP.check(imap_options, options_from_env) end