Skip to content

πŸ—‘οΈ Deprecate backward compatible parameters to new and starttls #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2023

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Sep 19, 2023

Since 2007, .new and #starttls have taken an options hash (bad0027) and the original parameters have been undocumented (e631911). The original usessl, certs, and verify parameters will now print a deprecation warning whenever they are used. In a future release (no sooner than a year after 0.4.0 is released), they will be removed from both methods.

The options hash has been converted to keyword parameters. An. sending port as the second argument to #initialize is also obsolete. Neither of them will print a deprecation warning, but they will be marked as deprecated in a future release.

To simplify the implementations of both #initialize and #starttls, the backwards compatible parameters have all been extracted to a DeprecatedClientOptions module, which is (currently) prepended to Net::IMAP.

Note: #174 accidentally included rdoc references to DeprecatedClientOptions, which is added by this PR.

@nevans
Copy link
Collaborator Author

nevans commented Sep 19, 2023

FYI: the mail gem currently uses the deprecated options to .new:
https://github.com/mikel/mail/blob/b6b6cb737d47a85ddc720fda0e6b991e99224848/lib/mail/network/retriever_methods/imap.rb#L167

        imap = Net::IMAP.new(settings[:address], settings[:port], settings[:enable_ssl], nil, false)

Not only that, but it sets verify_mode: VERIFY_NONE too!

Converts `Net::IMAP#initialize` to use keyword parameters for all
options.

Creates `Net::IMAP::DeprecatedClientOptions`, which is prepended to
`Net::IMAP` to override `#initialize`.  Moved all of the original
argument handling into it.

Obsolete, but not yet deprecated:
* Using an `options` hash instead of keyword parameters.
* Sending `port` as the second parameter.

Deprecated (will raise a warning):
* Setting `ssl` params via `usessl`, `certs`, or `verify` arguments.
`Net::IMAP#starttls` converts all incoming keyword args in params for
`OpenSSL::SSL::SSLContext#set_params`.
@nevans nevans force-pushed the deprecated-ssl-parameters branch from 5069f03 to 2066e7f Compare September 20, 2023 22:53
@nevans nevans merged commit 634854b into ruby:master Sep 21, 2023
@nevans nevans deleted the deprecated-ssl-parameters branch September 21, 2023 01:44
@nevans nevans mentioned this pull request Oct 3, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant