Upgrade mail to 2.8.1 for Ruby 3.1
We need to upgrade mail
since it brings in net-imap
, net-pop
, and net-smtp
as dependencies for Ruby 3.1.
It seems we have a monkey patch in config/initializers/mail_encoding_patch.rb
. I think some but not all of the patch can be removed. https://github.com/mikel/mail/pull/1210 was shipped in mail v2.8.0. It doesn't seem like it solves everything in !24153 (diffs). The maintainer asked for separate issues in https://github.com/mikel/mail/issues/1190#issuecomment-795904343.
https://gitlab.com/gitlab-org/gitlab/-/jobs/3919091804 is also failing:
Failures:
1) Gitlab::Email::Hook::ValidateAddressesInterceptor.delivering_email does not send emails if the :from header contains unsafe characters
Failure/Error: expect { mail.deliver_now }.not_to change(ActionMailer::Base.deliveries, :count)
expected `Array#count` not to have changed, but did change from 0 to 1
# ./spec/lib/gitlab/email/hook/validate_addresses_interceptor_spec.rb:39:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:502:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:494:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:490:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:490:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:242:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
2) Gitlab::Email::Hook::ValidateAddressesInterceptor.delivering_email does not send emails if the :to header contains unsafe characters
Failure/Error: expect { mail.deliver_now }.not_to change(ActionMailer::Base.deliveries, :count)
expected `Array#count` not to have changed, but did change from 0 to 1
# ./spec/lib/gitlab/email/hook/validate_addresses_interceptor_spec.rb:39:in `block (4 levels) in <main>'
# ./spec/spec_helper.rb:502:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:18:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:494:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:490:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:59:in `with_raw_context'
# ./spec/spec_helper.rb:490:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:242:in `block (2 levels) in <top (required)>'
# ./spec/support/system_exit_detected.rb:7:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:62:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:108:in `block (2 levels) in <main>'
Somehow the invalid mail from/to headers are being sanitized in the mail
gem now.
@@ -546,7 +547,7 @@ gem 'lru_redux'
# Locked as long as quoted-printable encoding issues are not resolved
# Monkey-patched in `config/initializers/mail_encoding_patch.rb`
# See https://gitlab.com/gitlab-org/gitlab/issues/197386
-gem 'mail', '= 2.7.1'
+gem 'mail', '= 2.8.1'
gem 'mail-smtp_pool', '~> 0.1.0', path: 'vendor/gems/mail-smtp_pool', require: false
gem 'microsoft_graph_mailer', '~> 0.1.0', path: 'vendor/gems/microsoft_graph_mailer'