net-imap 0.3.9 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of net-imap might be problematic. Click here for more details.

Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/BSDL +22 -0
  3. data/COPYING +56 -0
  4. data/Gemfile +14 -0
  5. data/LICENSE.txt +3 -22
  6. data/README.md +25 -8
  7. data/Rakefile +0 -7
  8. data/docs/styles.css +72 -23
  9. data/lib/net/imap/authenticators.rb +26 -57
  10. data/lib/net/imap/command_data.rb +74 -54
  11. data/lib/net/imap/config/attr_accessors.rb +75 -0
  12. data/lib/net/imap/config/attr_inheritance.rb +90 -0
  13. data/lib/net/imap/config/attr_type_coercion.rb +61 -0
  14. data/lib/net/imap/config.rb +470 -0
  15. data/lib/net/imap/data_encoding.rb +18 -6
  16. data/lib/net/imap/data_lite.rb +226 -0
  17. data/lib/net/imap/deprecated_client_options.rb +142 -0
  18. data/lib/net/imap/errors.rb +27 -35
  19. data/lib/net/imap/esearch_result.rb +180 -0
  20. data/lib/net/imap/fetch_data.rb +597 -0
  21. data/lib/net/imap/flags.rb +1 -1
  22. data/lib/net/imap/response_data.rb +250 -440
  23. data/lib/net/imap/response_parser/parser_utils.rb +245 -0
  24. data/lib/net/imap/response_parser.rb +1873 -1210
  25. data/lib/net/imap/sasl/anonymous_authenticator.rb +69 -0
  26. data/lib/net/imap/sasl/authentication_exchange.rb +139 -0
  27. data/lib/net/imap/sasl/authenticators.rb +122 -0
  28. data/lib/net/imap/sasl/client_adapter.rb +123 -0
  29. data/lib/net/imap/{authenticators/cram_md5.rb → sasl/cram_md5_authenticator.rb} +24 -14
  30. data/lib/net/imap/sasl/digest_md5_authenticator.rb +342 -0
  31. data/lib/net/imap/sasl/external_authenticator.rb +83 -0
  32. data/lib/net/imap/sasl/gs2_header.rb +80 -0
  33. data/lib/net/imap/{authenticators/login.rb → sasl/login_authenticator.rb} +28 -18
  34. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +199 -0
  35. data/lib/net/imap/sasl/plain_authenticator.rb +101 -0
  36. data/lib/net/imap/sasl/protocol_adapters.rb +101 -0
  37. data/lib/net/imap/sasl/scram_algorithm.rb +58 -0
  38. data/lib/net/imap/sasl/scram_authenticator.rb +287 -0
  39. data/lib/net/imap/sasl/stringprep.rb +6 -66
  40. data/lib/net/imap/sasl/xoauth2_authenticator.rb +106 -0
  41. data/lib/net/imap/sasl.rb +148 -44
  42. data/lib/net/imap/sasl_adapter.rb +20 -0
  43. data/lib/net/imap/search_result.rb +146 -0
  44. data/lib/net/imap/sequence_set.rb +1565 -0
  45. data/lib/net/imap/stringprep/nameprep.rb +70 -0
  46. data/lib/net/imap/stringprep/saslprep.rb +69 -0
  47. data/lib/net/imap/stringprep/saslprep_tables.rb +96 -0
  48. data/lib/net/imap/stringprep/tables.rb +146 -0
  49. data/lib/net/imap/stringprep/trace.rb +85 -0
  50. data/lib/net/imap/stringprep.rb +159 -0
  51. data/lib/net/imap/uidplus_data.rb +244 -0
  52. data/lib/net/imap/vanished_data.rb +56 -0
  53. data/lib/net/imap.rb +2109 -924
  54. data/net-imap.gemspec +7 -8
  55. data/rakelib/benchmarks.rake +91 -0
  56. data/rakelib/rfcs.rake +2 -0
  57. data/rakelib/saslprep.rake +4 -4
  58. data/rakelib/string_prep_tables_generator.rb +84 -60
  59. data/sample/net-imap.rb +167 -0
  60. metadata +45 -47
  61. data/.github/dependabot.yml +0 -6
  62. data/.github/workflows/test.yml +0 -38
  63. data/.gitignore +0 -10
  64. data/benchmarks/stringprep.yml +0 -65
  65. data/benchmarks/table-regexps.yml +0 -39
  66. data/lib/net/imap/authenticators/digest_md5.rb +0 -115
  67. data/lib/net/imap/authenticators/plain.rb +0 -41
  68. data/lib/net/imap/authenticators/xoauth2.rb +0 -20
  69. data/lib/net/imap/response_reader.rb +0 -75
  70. data/lib/net/imap/sasl/saslprep.rb +0 -55
  71. data/lib/net/imap/sasl/saslprep_tables.rb +0 -98
  72. data/lib/net/imap/sasl/stringprep_tables.rb +0 -153
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "date"
4
+ require "time"
4
5
 
5
6
  require_relative "errors"
6
7
 
@@ -102,8 +103,16 @@ module Net
102
103
  #
103
104
  # Decodes +string+ as an IMAP4 formatted "date-time".
104
105
  #
105
- # Note that double quotes are not optional. See STRFTIME.
106
+ # NOTE: Although double-quotes are not optional in the IMAP grammar,
107
+ # Net::IMAP currently parses "date-time" values as "quoted" strings and this
108
+ # removes the quotation marks. To be useful for strings which have already
109
+ # been parsed as a quoted string, this method makes double-quotes optional.
110
+ #
111
+ # See STRFTIME.
106
112
  def self.decode_datetime(string)
113
+ unless string.start_with?(?") && string.end_with?(?")
114
+ string = '"%s"' % [string]
115
+ end
107
116
  DateTime.strptime(string, STRFTIME)
108
117
  end
109
118
 
@@ -113,7 +122,10 @@ module Net
113
122
  #
114
123
  # Same as +decode_datetime+, but returning a Time instead.
115
124
  def self.decode_time(string)
116
- decode_datetime(string).to_time
125
+ unless string.start_with?(?") && string.end_with?(?")
126
+ string = '"%s"' % [string]
127
+ end
128
+ Time.strptime(string, STRFTIME)
117
129
  end
118
130
 
119
131
  class << self
@@ -124,7 +136,7 @@ module Net
124
136
  alias parse_datetime decode_datetime
125
137
  alias parse_time decode_time
126
138
 
127
- # alias format_datetime encode_datetime # n.b. this is overridden below...
139
+ # alias format_datetime encode_datetime # n.b: this is overridden below...
128
140
  end
129
141
 
130
142
  # DEPRECATED:: The original version returned incorrectly formatted strings.
@@ -174,7 +186,7 @@ module Net
174
186
 
175
187
  # Ensure argument is 'number' or raise DataFormatError
176
188
  def ensure_number(num)
177
- return if valid_number?(num)
189
+ return num if valid_number?(num)
178
190
 
179
191
  msg = "number must be unsigned 32-bit integer: #{num}"
180
192
  raise DataFormatError, msg
@@ -182,7 +194,7 @@ module Net
182
194
 
183
195
  # Ensure argument is 'nz_number' or raise DataFormatError
184
196
  def ensure_nz_number(num)
185
- return if valid_nz_number?(num)
197
+ return num if valid_nz_number?(num)
186
198
 
187
199
  msg = "nz_number must be non-zero unsigned 32-bit integer: #{num}"
188
200
  raise DataFormatError, msg
@@ -190,7 +202,7 @@ module Net
190
202
 
191
203
  # Ensure argument is 'mod_sequence_value' or raise DataFormatError
192
204
  def ensure_mod_sequence_value(num)
193
- return if valid_mod_sequence_value?(num)
205
+ return num if valid_mod_sequence_value?(num)
194
206
 
195
207
  msg = "mod_sequence_value must be unsigned 64-bit integer: #{num}"
196
208
  raise DataFormatError, msg
@@ -0,0 +1,226 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Some of the code in this file was copied from the polyfill-data gem.
4
+ #
5
+ # MIT License
6
+ #
7
+ # Copyright (c) 2023 Jim Gay, Joel Drapper, Nicholas Evans
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ # of this software and associated documentation files (the "Software"), to deal
11
+ # in the Software without restriction, including without limitation the rights
12
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ # copies of the Software, and to permit persons to whom the Software is
14
+ # furnished to do so, subject to the following conditions:
15
+ #
16
+ # The above copyright notice and this permission notice shall be included in all
17
+ # copies or substantial portions of the Software.
18
+ #
19
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ # SOFTWARE.
26
+
27
+
28
+ module Net
29
+ class IMAP
30
+ data_or_object = RUBY_VERSION >= "3.2.0" ? ::Data : Object
31
+ class DataLite < data_or_object
32
+ def encode_with(coder) coder.map = to_h.transform_keys(&:to_s) end
33
+ def init_with(coder) initialize(**coder.map.transform_keys(&:to_sym)) end
34
+ end
35
+
36
+ Data = DataLite
37
+ end
38
+ end
39
+
40
+ # :nocov:
41
+ # Need to skip test coverage for the rest, because it isn't loaded by ruby 3.2+.
42
+ return if RUBY_VERSION >= "3.2.0"
43
+
44
+ module Net
45
+ class IMAP
46
+ # DataLite is a temporary substitute for ruby 3.2's +Data+ class. DataLite
47
+ # is aliased as Net::IMAP::Data, so that code using it won't need to be
48
+ # updated when it is removed.
49
+ #
50
+ # See {ruby 3.2's documentation for Data}[https://docs.ruby-lang.org/en/3.2/Data.html].
51
+ #
52
+ # [When running ruby 3.1]
53
+ # This class reimplements the API for ruby 3.2's +Data+, and should be
54
+ # compatible for nearly all use-cases. This reimplementation <em>will be
55
+ # removed</em> in +net-imap+ 0.6, when support for ruby 3.1 is dropped.
56
+ #
57
+ # _NOTE:_ +net-imap+ no longer supports ruby versions prior to 3.1.
58
+ # [When running ruby >= 3.2]
59
+ # This class inherits from +Data+ and _only_ defines the methods needed
60
+ # for YAML serialization. This will be dropped when +psych+ adds support
61
+ # for +Data+.
62
+ #
63
+ # Some of the code in this class was copied or adapted from the
64
+ # {polyfill-data gem}[https://rubygems.org/gems/polyfill-data], by Jim Gay
65
+ # and Joel Drapper, under the MIT license terms.
66
+ class DataLite
67
+ singleton_class.undef_method :new
68
+
69
+ TYPE_ERROR = "%p is not a symbol nor a string"
70
+ ATTRSET_ERROR = "invalid data member: %p"
71
+ DUP_ERROR = "duplicate member: %p"
72
+ ARITY_ERROR = "wrong number of arguments (given %d, expected %s)"
73
+ private_constant :TYPE_ERROR, :ATTRSET_ERROR, :DUP_ERROR, :ARITY_ERROR
74
+
75
+ # Defines a new Data class.
76
+ #
77
+ # _NOTE:_ Unlike ruby 3.2's +Data.define+, DataLite.define only supports
78
+ # member names which are valid local variable names. Member names can't
79
+ # be keywords (e.g: +next+ or +class+) or start with capital letters, "@",
80
+ # etc.
81
+ def self.define(*args, &block)
82
+ members = args.each_with_object({}) do |arg, members|
83
+ arg = arg.to_str unless arg in Symbol | String if arg.respond_to?(:to_str)
84
+ arg = arg.to_sym if arg in String
85
+ arg in Symbol or raise TypeError, TYPE_ERROR % [arg]
86
+ arg in %r{=} and raise ArgumentError, ATTRSET_ERROR % [arg]
87
+ members.key?(arg) and raise ArgumentError, DUP_ERROR % [arg]
88
+ members[arg] = true
89
+ end
90
+ members = members.keys.freeze
91
+
92
+ klass = ::Class.new(self)
93
+
94
+ klass.singleton_class.undef_method :define
95
+ klass.define_singleton_method(:members) { members }
96
+
97
+ def klass.new(*args, **kwargs, &block)
98
+ if kwargs.size.positive?
99
+ if args.size.positive?
100
+ raise ArgumentError, ARITY_ERROR % [args.size, 0]
101
+ end
102
+ elsif members.size < args.size
103
+ expected = members.size.zero? ? 0 : 0..members.size
104
+ raise ArgumentError, ARITY_ERROR % [args.size, expected]
105
+ else
106
+ kwargs = Hash[members.take(args.size).zip(args)]
107
+ end
108
+ allocate.tap do |instance|
109
+ instance.__send__(:initialize, **kwargs, &block)
110
+ end.freeze
111
+ end
112
+
113
+ klass.singleton_class.alias_method :[], :new
114
+ klass.attr_reader(*members)
115
+
116
+ # Dynamically defined initializer methods are in an included module,
117
+ # rather than directly on DataLite (like in ruby 3.2+):
118
+ # * simpler to handle required kwarg ArgumentErrors
119
+ # * easier to ensure consistent ivar assignment order (object shape)
120
+ # * faster than instance_variable_set
121
+ klass.include(Module.new do
122
+ if members.any?
123
+ kwargs = members.map{"#{_1.name}:"}.join(", ")
124
+ params = members.map(&:name).join(", ")
125
+ ivars = members.map{"@#{_1.name}"}.join(", ")
126
+ attrs = members.map{"attrs[:#{_1.name}]"}.join(", ")
127
+ module_eval <<~RUBY, __FILE__, __LINE__ + 1
128
+ protected
129
+ def initialize(#{kwargs}) #{ivars} = #{params}; freeze end
130
+ def marshal_load(attrs) #{ivars} = #{attrs}; freeze end
131
+ RUBY
132
+ end
133
+ end)
134
+
135
+ klass.module_eval do _1.module_eval(&block) end if block_given?
136
+
137
+ klass
138
+ end
139
+
140
+ ##
141
+ # singleton-method: new
142
+ # call-seq:
143
+ # new(*args) -> instance
144
+ # new(**kwargs) -> instance
145
+ #
146
+ # Constuctor for classes defined with ::define.
147
+ #
148
+ # Aliased as ::[].
149
+
150
+ ##
151
+ # singleton-method: []
152
+ # call-seq:
153
+ # ::[](*args) -> instance
154
+ # ::[](**kwargs) -> instance
155
+ #
156
+ # Constuctor for classes defined with ::define.
157
+ #
158
+ # Alias for ::new
159
+
160
+ ##
161
+ def members; self.class.members end
162
+ def to_h(&block) block ? __to_h__.to_h(&block) : __to_h__ end
163
+ def hash; [self.class, __to_h__].hash end
164
+ def ==(other) self.class == other.class && to_h == other.to_h end
165
+ def eql?(other) self.class == other.class && hash == other.hash end
166
+ def deconstruct; __to_h__.values end
167
+
168
+ def deconstruct_keys(keys)
169
+ raise TypeError unless keys.is_a?(Array) || keys.nil?
170
+ return __to_h__ if keys&.first.nil?
171
+ __to_h__.slice(*keys)
172
+ end
173
+
174
+ def with(**kwargs)
175
+ return self if kwargs.empty?
176
+ self.class.new(**__to_h__.merge(kwargs))
177
+ end
178
+
179
+ def inspect
180
+ __inspect_guard__(self) do |seen|
181
+ return "#<data #{self.class}:...>" if seen
182
+ attrs = __to_h__.map {|kv| "%s=%p" % kv }.join(", ")
183
+ display = ["data", self.class.name, attrs].compact.join(" ")
184
+ "#<#{display}>"
185
+ end
186
+ end
187
+ alias_method :to_s, :inspect
188
+
189
+ private
190
+
191
+ def initialize_copy(source) super.freeze end
192
+ def marshal_dump; __to_h__ end
193
+
194
+ def __to_h__; Hash[members.map {|m| [m, send(m)] }] end
195
+
196
+ # Yields +true+ if +obj+ has been seen already, +false+ if it hasn't.
197
+ # Marks +obj+ as seen inside the block, so circuler references don't
198
+ # recursively trigger a SystemStackError (stack level too deep).
199
+ #
200
+ # Making circular references inside a Data object _should_ be very
201
+ # uncommon, but we'll support them for the sake of completeness.
202
+ def __inspect_guard__(obj)
203
+ preexisting = Thread.current[:__net_imap_data__inspect__]
204
+ Thread.current[:__net_imap_data__inspect__] ||= {}.compare_by_identity
205
+ inspect_guard = Thread.current[:__net_imap_data__inspect__]
206
+ if inspect_guard.include?(obj)
207
+ yield true
208
+ else
209
+ begin
210
+ inspect_guard[obj] = true
211
+ yield false
212
+ ensure
213
+ inspect_guard.delete(obj)
214
+ end
215
+ end
216
+ ensure
217
+ unless preexisting.equal?(inspect_guard)
218
+ Thread.current[:__net_imap_data__inspect__] = preexisting
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ end
225
+ end
226
+ # :nocov:
@@ -0,0 +1,142 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Net
4
+ class IMAP < Protocol
5
+
6
+ # This module handles deprecated arguments to various Net::IMAP methods.
7
+ module DeprecatedClientOptions
8
+
9
+ # :call-seq:
10
+ # Net::IMAP.new(host, **options) # standard keyword options
11
+ # Net::IMAP.new(host, options) # obsolete hash options
12
+ # Net::IMAP.new(host, port) # obsolete port argument
13
+ # Net::IMAP.new(host, port, usessl, certs = nil, verify = true) # deprecated SSL arguments
14
+ #
15
+ # Translates Net::IMAP.new arguments for backward compatibility.
16
+ #
17
+ # ==== Obsolete arguments
18
+ #
19
+ # Use of obsolete arguments does not print a warning. Obsolete arguments
20
+ # will be deprecated by a future release.
21
+ #
22
+ # If a second positional argument is given and it is a hash (or is
23
+ # convertible via +#to_hash+), it is converted to keyword arguments.
24
+ #
25
+ # # Obsolete:
26
+ # Net::IMAP.new("imap.example.com", options_hash)
27
+ # # Use instead:
28
+ # Net::IMAP.new("imap.example.com", **options_hash)
29
+ #
30
+ # If a second positional argument is given and it is not a hash, it is
31
+ # converted to the +port+ keyword argument.
32
+ # # Obsolete:
33
+ # Net::IMAP.new("imap.example.com", 114433)
34
+ # # Use instead:
35
+ # Net::IMAP.new("imap.example.com", port: 114433)
36
+ #
37
+ # ==== Deprecated arguments
38
+ #
39
+ # Using deprecated arguments prints a warning. Convert to keyword
40
+ # arguments to avoid the warning. Deprecated arguments will be removed in
41
+ # a future release.
42
+ #
43
+ # If +usessl+ is false, +certs+, and +verify+ are ignored. When it true,
44
+ # all three arguments are converted to the +ssl+ keyword argument.
45
+ # Without +certs+ or +verify+, it is converted to <tt>ssl: true</tt>.
46
+ # # DEPRECATED:
47
+ # Net::IMAP.new("imap.example.com", nil, true) # => prints a warning
48
+ # # Use instead:
49
+ # Net::IMAP.new("imap.example.com", ssl: true)
50
+ #
51
+ # When +certs+ is a path to a directory, it is converted to <tt>ca_path:
52
+ # certs</tt>.
53
+ # # DEPRECATED:
54
+ # Net::IMAP.new("imap.example.com", nil, true, "/path/to/certs") # => prints a warning
55
+ # # Use instead:
56
+ # Net::IMAP.new("imap.example.com", ssl: {ca_path: "/path/to/certs"})
57
+ #
58
+ # When +certs+ is a path to a file, it is converted to <tt>ca_file:
59
+ # certs</tt>.
60
+ # # DEPRECATED:
61
+ # Net::IMAP.new("imap.example.com", nil, true, "/path/to/cert.pem") # => prints a warning
62
+ # # Use instead:
63
+ # Net::IMAP.new("imap.example.com", ssl: {ca_file: "/path/to/cert.pem"})
64
+ #
65
+ # When +verify+ is +false+, it is converted to <tt>verify_mode:
66
+ # OpenSSL::SSL::VERIFY_NONE</tt>.
67
+ # # DEPRECATED:
68
+ # Net::IMAP.new("imap.example.com", nil, true, nil, false) # => prints a warning
69
+ # # Use instead:
70
+ # Net::IMAP.new("imap.example.com", ssl: {verify_mode: OpenSSL::SSL::VERIFY_NONE})
71
+ #
72
+ def initialize(host, port_or_options = nil, *deprecated, **options)
73
+ if port_or_options.nil? && deprecated.empty?
74
+ super host, **options
75
+ elsif options.any?
76
+ # Net::IMAP.new(host, *__invalid__, **options)
77
+ raise ArgumentError, "Do not combine deprecated and keyword arguments"
78
+ elsif port_or_options.respond_to?(:to_hash) and deprecated.any?
79
+ # Net::IMAP.new(host, options, *__invalid__)
80
+ raise ArgumentError, "Do not use deprecated SSL params with options hash"
81
+ elsif port_or_options.respond_to?(:to_hash)
82
+ super host, **Hash.try_convert(port_or_options)
83
+ elsif deprecated.empty?
84
+ super host, port: port_or_options
85
+ elsif deprecated.shift
86
+ warn("DEPRECATED: Call Net::IMAP.new with keyword options",
87
+ uplevel: 1, category: :deprecated)
88
+ super host, port: port_or_options, ssl: create_ssl_params(*deprecated)
89
+ else
90
+ warn("DEPRECATED: Call Net::IMAP.new with keyword options",
91
+ uplevel: 1, category: :deprecated)
92
+ super host, port: port_or_options, ssl: false
93
+ end
94
+ end
95
+
96
+ # :call-seq:
97
+ # starttls(**options) # standard
98
+ # starttls(options = {}) # obsolete
99
+ # starttls(certs = nil, verify = true) # deprecated
100
+ #
101
+ # Translates Net::IMAP#starttls arguments for backward compatibility.
102
+ #
103
+ # Support for +certs+ and +verify+ will be dropped in a future release.
104
+ #
105
+ # See ::new for interpretation of +certs+ and +verify+.
106
+ def starttls(*deprecated, **options)
107
+ if deprecated.empty?
108
+ super(**options)
109
+ elsif options.any?
110
+ # starttls(*__invalid__, **options)
111
+ raise ArgumentError, "Do not combine deprecated and keyword options"
112
+ elsif deprecated.first.respond_to?(:to_hash) && deprecated.length > 1
113
+ # starttls(*__invalid__, **options)
114
+ raise ArgumentError, "Do not use deprecated verify param with options hash"
115
+ elsif deprecated.first.respond_to?(:to_hash)
116
+ super(**Hash.try_convert(deprecated.first))
117
+ else
118
+ warn("DEPRECATED: Call Net::IMAP#starttls with keyword options",
119
+ uplevel: 1, category: :deprecated)
120
+ super(**create_ssl_params(*deprecated))
121
+ end
122
+ end
123
+
124
+ private
125
+
126
+ def create_ssl_params(certs = nil, verify = true)
127
+ params = {}
128
+ if certs
129
+ if File.file?(certs)
130
+ params[:ca_file] = certs
131
+ elsif File.directory?(certs)
132
+ params[:ca_path] = certs
133
+ end
134
+ end
135
+ params[:verify_mode] =
136
+ verify ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
137
+ params
138
+ end
139
+
140
+ end
141
+ end
142
+ end
@@ -7,45 +7,17 @@ module Net
7
7
  class Error < StandardError
8
8
  end
9
9
 
10
- # Error raised when data is in the incorrect format.
11
- class DataFormatError < Error
12
- end
13
-
14
- # Error raised when the socket cannot be read, due to a configured limit.
15
- class ResponseReadError < Error
16
- end
17
-
18
- # Error raised when a response is larger than IMAP#max_response_size.
19
- class ResponseTooLargeError < ResponseReadError
20
- attr_reader :bytes_read, :literal_size
21
- attr_reader :max_response_size
22
-
23
- def initialize(msg = nil, *args,
24
- bytes_read: nil,
25
- literal_size: nil,
26
- max_response_size: nil,
27
- **kwargs)
28
- @bytes_read = bytes_read
29
- @literal_size = literal_size
30
- @max_response_size = max_response_size
31
- msg ||= [
32
- "Response size", response_size_msg, "exceeds max_response_size",
33
- max_response_size && "(#{max_response_size}B)",
34
- ].compact.join(" ")
35
- return super(msg, *args) if kwargs.empty? # ruby 2.6 compatibility
36
- super(msg, *args, **kwargs)
10
+ class LoginDisabledError < Error
11
+ def initialize(msg = "Remote server has disabled the LOGIN command", ...)
12
+ super
37
13
  end
14
+ end
38
15
 
39
- private
40
-
41
- def response_size_msg
42
- if bytes_read && literal_size
43
- "(#{bytes_read}B read + #{literal_size}B literal)"
44
- end
45
- end
16
+ # Error raised when data is in the incorrect format.
17
+ class DataFormatError < Error
46
18
  end
47
19
 
48
- # Error raised when a response from the server is non-parseable.
20
+ # Error raised when a response from the server is non-parsable.
49
21
  class ResponseParseError < Error
50
22
  end
51
23
 
@@ -81,7 +53,27 @@ module Net
81
53
  class ByeResponseError < ResponseError
82
54
  end
83
55
 
56
+ # Error raised when the server sends an invalid response.
57
+ #
58
+ # This is different from UnknownResponseError: the response has been
59
+ # rejected. Although it may be parsable, the server is forbidden from
60
+ # sending it in the current context. The client should automatically
61
+ # disconnect, abruptly (without logout).
62
+ #
63
+ # Note that InvalidResponseError does not inherit from ResponseError: it
64
+ # can be raised before the response is fully parsed. A related
65
+ # ResponseParseError or ResponseError may be the #cause.
66
+ class InvalidResponseError < Error
67
+ end
68
+
84
69
  # Error raised upon an unknown response from the server.
70
+ #
71
+ # This is different from InvalidResponseError: the response may be a
72
+ # valid extension response and the server may be allowed to send it in
73
+ # this context, but Net::IMAP either does not know how to parse it or
74
+ # how to handle it. This could result from enabling unknown or
75
+ # unhandled extensions. The connection may still be usable,
76
+ # but—depending on context—it may be prudent to disconnect.
85
77
  class UnknownResponseError < ResponseError
86
78
  end
87
79