net-imap 0.4.17 → 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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -1
  3. data/README.md +10 -4
  4. data/docs/styles.css +75 -14
  5. data/lib/net/imap/authenticators.rb +2 -2
  6. data/lib/net/imap/command_data.rb +59 -46
  7. data/lib/net/imap/config.rb +109 -13
  8. data/lib/net/imap/data_encoding.rb +3 -3
  9. data/lib/net/imap/data_lite.rb +226 -0
  10. data/lib/net/imap/deprecated_client_options.rb +6 -3
  11. data/lib/net/imap/errors.rb +6 -0
  12. data/lib/net/imap/esearch_result.rb +180 -0
  13. data/lib/net/imap/fetch_data.rb +126 -47
  14. data/lib/net/imap/response_data.rb +124 -237
  15. data/lib/net/imap/response_parser/parser_utils.rb +5 -0
  16. data/lib/net/imap/response_parser.rb +183 -34
  17. data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -3
  18. data/lib/net/imap/sasl/authentication_exchange.rb +52 -20
  19. data/lib/net/imap/sasl/authenticators.rb +8 -4
  20. data/lib/net/imap/sasl/client_adapter.rb +77 -26
  21. data/lib/net/imap/sasl/cram_md5_authenticator.rb +4 -4
  22. data/lib/net/imap/sasl/digest_md5_authenticator.rb +218 -56
  23. data/lib/net/imap/sasl/external_authenticator.rb +2 -2
  24. data/lib/net/imap/sasl/gs2_header.rb +7 -7
  25. data/lib/net/imap/sasl/login_authenticator.rb +4 -3
  26. data/lib/net/imap/sasl/oauthbearer_authenticator.rb +6 -6
  27. data/lib/net/imap/sasl/plain_authenticator.rb +7 -7
  28. data/lib/net/imap/sasl/protocol_adapters.rb +60 -4
  29. data/lib/net/imap/sasl/scram_authenticator.rb +8 -8
  30. data/lib/net/imap/sasl.rb +7 -4
  31. data/lib/net/imap/sasl_adapter.rb +0 -1
  32. data/lib/net/imap/search_result.rb +2 -2
  33. data/lib/net/imap/sequence_set.rb +211 -81
  34. data/lib/net/imap/stringprep/nameprep.rb +1 -1
  35. data/lib/net/imap/stringprep/trace.rb +4 -4
  36. data/lib/net/imap/uidplus_data.rb +244 -0
  37. data/lib/net/imap/vanished_data.rb +56 -0
  38. data/lib/net/imap.rb +831 -279
  39. data/net-imap.gemspec +1 -1
  40. data/rakelib/rfcs.rake +2 -0
  41. data/rakelib/string_prep_tables_generator.rb +2 -0
  42. metadata +8 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aceea6e339f24fafdd1920f2b25d863b47823c5654528441e4c7d173e414f3c2
4
- data.tar.gz: 6258659759ae4c6b7ea63f7dddf0fb4a7231c3242ebad72188ba43bb7a2f3165
3
+ metadata.gz: cdbdda0ed73da899ec338f66022a16104562d3701c568b0a6d4897270a608ac5
4
+ data.tar.gz: b6a7ec70776b32f8eb57d01a0869503eb5d76f719ac091eb92e0206608e936e9
5
5
  SHA512:
6
- metadata.gz: 003561bf18250b9237f10d5ba5ce20ea285dea1d0380f4612d08429fe31ceea14d84fef76dc4e6c5ba47ff2e798b20a7767d85f6cdeb79f7abfcdb25df39093f
7
- data.tar.gz: 42702bd43a0f9e778c88017e1553a5ddd058c0b702f1c39843c845ef0fba935b2f3ee636dc10a700e23b89c3e9a9e5b9c80b8bff836e65985bc59ca73c2a6255
6
+ metadata.gz: 381bf2428719ed8decb5d241fda0e19f28031dd4a77980b3717bb29c37bed1c927f00e5b57862e209ecf24b2e9b38c01088d6e1a90fc4b4cc026cdd9e6611100
7
+ data.tar.gz: 513c6a77d46b6d2cf67aea4511023acc76c69940e3b1a0d0eae7223b53ff63bc8e6e009f51fef826b09f76f6ad1d92e84243e8457f59d3912db7e74bf69d3d1b
data/Gemfile CHANGED
@@ -8,9 +8,16 @@ gem "digest"
8
8
  gem "strscan"
9
9
  gem "base64"
10
10
 
11
+ gem "irb"
11
12
  gem "rake"
12
13
  gem "rdoc"
13
14
  gem "test-unit"
14
15
  gem "test-unit-ruby-core", git: "https://github.com/ruby/test-unit-ruby-core"
15
16
 
16
- gem "benchmark-driver"
17
+ gem "benchmark-driver", require: false
18
+
19
+ group :test do
20
+ gem "simplecov", require: false
21
+ gem "simplecov-html", require: false
22
+ gem "simplecov-json", require: false
23
+ end
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Net::IMAP
2
2
 
3
3
  Net::IMAP implements Internet Message Access Protocol (IMAP) client
4
- functionality. The protocol is described in [IMAP](https://tools.ietf.org/html/rfc3501).
4
+ functionality. The protocol is described in
5
+ [RFC3501](https://www.rfc-editor.org/rfc/rfc3501),
6
+ [RFC9051](https://www.rfc-editor.org/rfc/rfc9051) and various extensions.
5
7
 
6
8
  ## Installation
7
9
 
@@ -50,12 +52,16 @@ end
50
52
 
51
53
  ```ruby
52
54
  imap.select('Mail/sent-mail')
53
- if not imap.list('Mail/', 'sent-apr03')
55
+ if imap.list('Mail/', 'sent-apr03').empty?
54
56
  imap.create('Mail/sent-apr03')
55
57
  end
56
58
  imap.search(["BEFORE", "30-Apr-2003", "SINCE", "1-Apr-2003"]).each do |message_id|
57
- imap.copy(message_id, "Mail/sent-apr03")
58
- imap.store(message_id, "+FLAGS", [:Deleted])
59
+ if imap.capable?(:move) || imap.capable?(:IMAP4rev2)
60
+ imap.move(message_id, "Mail/sent-apr03")
61
+ else
62
+ imap.copy(message_id, "Mail/sent-apr03")
63
+ imap.store(message_id, "+FLAGS", [:Deleted])
64
+ end
59
65
  end
60
66
  imap.expunge
61
67
  ```
data/docs/styles.css CHANGED
@@ -1,24 +1,85 @@
1
1
  /* this is a work in progress. :) */
2
2
 
3
- main .method-header {
4
- background: rgba(27,31,35,0.05);
5
- border: 1px solid #6C8C22;
3
+ /***********************************************
4
+ * Method descriptions
5
+ ***********************************************/
6
+
7
+ main .method-detail {
8
+ display: grid;
9
+ grid-template-columns: 1fr auto;
10
+ justify-content: space-between;
11
+ }
12
+
13
+ main .method-header,
14
+ main .method-controls,
15
+ .attribute-method-heading {
6
16
  padding: 0.5em;
7
- border-radius: 4px;
8
- /* padding: 0 0.5em; */
9
- /* border-width: 0 1px; */
10
- /* border-color: #6C8C22; */
11
- /* border-style: solid; */
17
+ /* border: 1px solid var(--highlight-color); */
18
+ background: var(--table-header-background-color);
19
+ line-height: 1.6;
20
+ }
21
+
22
+ .attribute-method-heading .attribute-access-type {
23
+ float: right;
24
+ }
25
+
26
+ main .method-header {
27
+ border-right: none;
28
+ border-radius: 4px 0 0 4px;
29
+ }
30
+
31
+ main .method-heading :any-link {
32
+ text-decoration: none;
33
+ }
34
+
35
+ main .method-controls {
36
+ border-left: none;
37
+ border-radius: 0 4px 4px 0;
12
38
  }
13
39
 
14
40
  main .method-description, main .aliases {
41
+ grid-column: 1 / span 2;
15
42
  padding-left: 1em;
16
43
  }
17
44
 
18
- body {
19
- /*
20
- * The default (300) can be too low contrast. Also, many fonts don't
21
- * distinguish between 300->400, so <em>...</em> had no effect.
22
- */
23
- font-weight: 400;
45
+ @media (max-width: 700px) {
46
+ main .method-header, main .method-controls, main .method-description {
47
+ grid-column: 1 / span 2;
48
+ margin: 0;
49
+ }
50
+ main .method-controls {
51
+ background: none;
52
+ }
53
+ }
54
+
55
+ /***********************************************
56
+ * Description lists
57
+ ***********************************************/
58
+
59
+ main dt {
60
+ margin-bottom: 0; /* override rdoc 6.8 */
61
+ float: unset; /* override rdoc 6.8 */
62
+ line-height: 1.5; /* matches `main p` */
63
+ }
64
+
65
+ main dl.note-list dt {
66
+ margin-right: 1em;
67
+ float: left;
68
+ }
69
+
70
+ main dl.note-list dt:has(+ dt) {
71
+ margin-right: 0.25em;
72
+ }
73
+
74
+ main dl.note-list dt:has(+ dt)::after {
75
+ content: ', ';
76
+ font-weight: normal;
77
+ }
78
+
79
+ main dd {
80
+ margin: 0 0 1em 1em;
81
+ }
82
+
83
+ main dd p:first-child {
84
+ margin-top: 0;
24
85
  }
@@ -9,7 +9,7 @@ module Net::IMAP::Authenticators
9
9
  "%s.%s is deprecated. Use %s.%s instead." % [
10
10
  Net::IMAP, __method__, Net::IMAP::SASL, __method__
11
11
  ],
12
- uplevel: 1
12
+ uplevel: 1, category: :deprecated
13
13
  )
14
14
  Net::IMAP::SASL.add_authenticator(...)
15
15
  end
@@ -20,7 +20,7 @@ module Net::IMAP::Authenticators
20
20
  "%s.%s is deprecated. Use %s.%s instead." % [
21
21
  Net::IMAP, __method__, Net::IMAP::SASL, __method__
22
22
  ],
23
- uplevel: 1
23
+ uplevel: 1, category: :deprecated
24
24
  )
25
25
  Net::IMAP::SASL.authenticator(...)
26
26
  end
@@ -3,6 +3,7 @@
3
3
  require "date"
4
4
 
5
5
  require_relative "errors"
6
+ require_relative "data_lite"
6
7
 
7
8
  module Net
8
9
  class IMAP < Protocol
@@ -119,79 +120,95 @@ module Net
119
120
  put_string("\\" + symbol.to_s)
120
121
  end
121
122
 
122
- class RawData # :nodoc:
123
+ CommandData = Data.define(:data) do # :nodoc:
123
124
  def send_data(imap, tag)
124
- imap.__send__(:put_string, @data)
125
+ raise NoMethodError, "#{self.class} must implement #{__method__}"
125
126
  end
126
127
 
127
128
  def validate
128
129
  end
129
-
130
- private
131
-
132
- def initialize(data)
133
- @data = data
134
- end
135
130
  end
136
131
 
137
- class Atom # :nodoc:
132
+ class RawData < CommandData # :nodoc:
138
133
  def send_data(imap, tag)
139
- imap.__send__(:put_string, @data)
140
- end
141
-
142
- def validate
143
- end
144
-
145
- private
146
-
147
- def initialize(data)
148
- @data = data
134
+ imap.__send__(:put_string, data)
149
135
  end
150
136
  end
151
137
 
152
- class QuotedString # :nodoc:
138
+ class Atom < CommandData # :nodoc:
153
139
  def send_data(imap, tag)
154
- imap.__send__(:send_quoted_string, @data)
140
+ imap.__send__(:put_string, data)
155
141
  end
142
+ end
156
143
 
157
- def validate
158
- end
159
-
160
- private
161
-
162
- def initialize(data)
163
- @data = data
144
+ class QuotedString < CommandData # :nodoc:
145
+ def send_data(imap, tag)
146
+ imap.__send__(:send_quoted_string, data)
164
147
  end
165
148
  end
166
149
 
167
- class Literal # :nodoc:
150
+ class Literal < CommandData # :nodoc:
168
151
  def send_data(imap, tag)
169
- imap.__send__(:send_literal, @data, tag)
152
+ imap.__send__(:send_literal, data, tag)
170
153
  end
154
+ end
171
155
 
172
- def validate
156
+ class PartialRange < CommandData # :nodoc:
157
+ uint32_max = 2**32 - 1
158
+ POS_RANGE = 1..uint32_max
159
+ NEG_RANGE = -uint32_max..-1
160
+ Positive = ->{ (_1 in Range) and POS_RANGE.cover?(_1) }
161
+ Negative = ->{ (_1 in Range) and NEG_RANGE.cover?(_1) }
162
+
163
+ def initialize(data:)
164
+ min, max = case data
165
+ in Range
166
+ data.minmax.map { Integer _1 }
167
+ in ResponseParser::Patterns::PARTIAL_RANGE
168
+ data.split(":").map { Integer _1 }.minmax
169
+ else
170
+ raise ArgumentError, "invalid partial range input: %p" % [data]
171
+ end
172
+ data = min..max
173
+ unless data in Positive | Negative
174
+ raise ArgumentError, "invalid partial-range: %p" % [data]
175
+ end
176
+ super
177
+ rescue TypeError, RangeError
178
+ raise ArgumentError, "expected range min/max to be Integers"
173
179
  end
174
180
 
175
- private
181
+ def formatted = "%d:%d" % data.minmax
176
182
 
177
- def initialize(data)
178
- @data = data
183
+ def send_data(imap, tag)
184
+ imap.__send__(:put_string, formatted)
179
185
  end
180
186
  end
181
187
 
182
- class MessageSet # :nodoc:
188
+ # *DEPRECATED*. Replaced by SequenceSet.
189
+ class MessageSet < CommandData # :nodoc:
183
190
  def send_data(imap, tag)
184
- imap.__send__(:put_string, format_internal(@data))
191
+ imap.__send__(:put_string, format_internal(data))
185
192
  end
186
193
 
187
194
  def validate
188
- validate_internal(@data)
195
+ validate_internal(data)
189
196
  end
190
197
 
191
198
  private
192
199
 
193
- def initialize(data)
194
- @data = data
200
+ def initialize(data:)
201
+ super
202
+ warn("DEPRECATED: #{MessageSet} should be replaced with #{SequenceSet}.",
203
+ uplevel: 1, category: :deprecated)
204
+ begin
205
+ # to ensure the input works with SequenceSet, too
206
+ SequenceSet.new(data)
207
+ rescue
208
+ warn "MessageSet input is incompatible with SequenceSet: [%s] %s" % [
209
+ $!.class, $!.message
210
+ ]
211
+ end
195
212
  end
196
213
 
197
214
  def format_internal(data)
@@ -235,22 +252,18 @@ module Net
235
252
  end
236
253
  end
237
254
 
238
- class ClientID # :nodoc:
255
+ class ClientID < CommandData # :nodoc:
239
256
 
240
257
  def send_data(imap, tag)
241
- imap.__send__(:send_data, format_internal(@data), tag)
258
+ imap.__send__(:send_data, format_internal(data), tag)
242
259
  end
243
260
 
244
261
  def validate
245
- validate_internal(@data)
262
+ validate_internal(data)
246
263
  end
247
264
 
248
265
  private
249
266
 
250
- def initialize(data)
251
- @data = data
252
- end
253
-
254
267
  def validate_internal(client_id)
255
268
  client_id.to_h.each do |k,v|
256
269
  unless StringFormatter.valid_string?(k)
@@ -75,7 +75,7 @@ module Net
75
75
  #
76
76
  # client = Net::IMAP.new(hostname, config: :future)
77
77
  # client.config.sasl_ir # => true
78
- # client.config.responses_without_block # => :raise
78
+ # client.config.responses_without_block # => :frozen_dup
79
79
  #
80
80
  # The versioned default configs inherit certain specific config options from
81
81
  # Config.global, for example #debug:
@@ -109,9 +109,11 @@ module Net
109
109
  # [+:future+]
110
110
  # The _planned_ eventual config for some future +x.y+ version.
111
111
  #
112
- # For example, to raise exceptions for all current deprecations:
112
+ # For example, to disable all currently deprecated behavior:
113
113
  # client = Net::IMAP.new(hostname, config: :future)
114
- # client.responses # raises an ArgumentError
114
+ # client.config.response_without_args # => :frozen_dup
115
+ # client.responses.frozen? # => true
116
+ # client.responses.values.all?(&:frozen?) # => true
115
117
  #
116
118
  # == Thread Safety
117
119
  #
@@ -223,6 +225,29 @@ module Net
223
225
  # Use +SASL-IR+ when it is supported by the server and the mechanism.
224
226
  attr_accessor :sasl_ir, type: :boolean
225
227
 
228
+ # Controls the behavior of Net::IMAP#login when the +LOGINDISABLED+
229
+ # capability is present. When enforced, Net::IMAP will raise a
230
+ # LoginDisabledError when that capability is present.
231
+ #
232
+ # <em>(Support for +LOGINDISABLED+ was added in +v0.5.0+.)</em>
233
+ #
234
+ # ==== Valid options
235
+ #
236
+ # [+false+ <em>(original behavior, before support was added)</em>]
237
+ # Send the +LOGIN+ command without checking for +LOGINDISABLED+.
238
+ #
239
+ # [+:when_capabilities_cached+]
240
+ # Enforce the requirement when Net::IMAP#capabilities_cached? is true,
241
+ # but do not send a +CAPABILITY+ command to discover the capabilities.
242
+ #
243
+ # [+true+ <em>(default since +v0.5+)</em>]
244
+ # Only send the +LOGIN+ command if the +LOGINDISABLED+ capability is not
245
+ # present. When capabilities are unknown, Net::IMAP will automatically
246
+ # send a +CAPABILITY+ command first before sending +LOGIN+.
247
+ #
248
+ attr_accessor :enforce_logindisabled, type: [
249
+ false, :when_capabilities_cached, true
250
+ ]
226
251
 
227
252
  # Controls the behavior of Net::IMAP#responses when called without any
228
253
  # arguments (+type+ or +block+).
@@ -262,6 +287,67 @@ module Net
262
287
  #
263
288
  # Alias for responses_without_block
264
289
 
290
+ # Whether ResponseParser should use the deprecated UIDPlusData or
291
+ # CopyUIDData for +COPYUID+ response codes, and UIDPlusData or
292
+ # AppendUIDData for +APPENDUID+ response codes.
293
+ #
294
+ # UIDPlusData stores its data in arrays of numbers, which is vulnerable to
295
+ # a memory exhaustion denial of service attack from an untrusted or
296
+ # compromised server. Set this option to +false+ to completely block this
297
+ # vulnerability. Otherwise, parser_max_deprecated_uidplus_data_size
298
+ # mitigates this vulnerability.
299
+ #
300
+ # AppendUIDData and CopyUIDData are _mostly_ backward-compatible with
301
+ # UIDPlusData. Most applications should be able to upgrade with little
302
+ # or no changes.
303
+ #
304
+ # <em>(Parser support for +UIDPLUS+ added in +v0.3.2+.)</em>
305
+ #
306
+ # <em>(Config option added in +v0.4.19+ and +v0.5.6+.)</em>
307
+ #
308
+ # <em>UIDPlusData will be removed in +v0.6+ and this config setting will
309
+ # be ignored.</em>
310
+ #
311
+ # ==== Valid options
312
+ #
313
+ # [+true+ <em>(original default)</em>]
314
+ # ResponseParser only uses UIDPlusData.
315
+ #
316
+ # [+:up_to_max_size+ <em>(default since +v0.5.6+)</em>]
317
+ # ResponseParser uses UIDPlusData when the +uid-set+ size is below
318
+ # parser_max_deprecated_uidplus_data_size. Above that size,
319
+ # ResponseParser uses AppendUIDData or CopyUIDData.
320
+ #
321
+ # [+false+ <em>(planned default for +v0.6+)</em>]
322
+ # ResponseParser _only_ uses AppendUIDData and CopyUIDData.
323
+ attr_accessor :parser_use_deprecated_uidplus_data, type: [
324
+ true, :up_to_max_size, false
325
+ ]
326
+
327
+ # The maximum +uid-set+ size that ResponseParser will parse into
328
+ # deprecated UIDPlusData. This limit only applies when
329
+ # parser_use_deprecated_uidplus_data is not +false+.
330
+ #
331
+ # <em>(Parser support for +UIDPLUS+ added in +v0.3.2+.)</em>
332
+ #
333
+ # <em>Support for limiting UIDPlusData to a maximum size was added in
334
+ # +v0.3.8+, +v0.4.19+, and +v0.5.6+.</em>
335
+ #
336
+ # <em>UIDPlusData will be removed in +v0.6+.</em>
337
+ #
338
+ # ==== Versioned Defaults
339
+ #
340
+ # Because this limit guards against a remote server causing catastrophic
341
+ # memory exhaustion, the versioned default (used by #load_defaults) also
342
+ # applies to versions without the feature.
343
+ #
344
+ # * +0.3+ and prior: <tt>10,000</tt>
345
+ # * +0.4+: <tt>1,000</tt>
346
+ # * +0.5+: <tt>100</tt>
347
+ # * +0.6+: <tt>0</tt>
348
+ #
349
+ attr_accessor :parser_max_deprecated_uidplus_data_size, type: Integer
350
+
265
351
  # Creates a new config object and initialize its attribute with +attrs+.
266
352
  #
267
353
  # If +parent+ is not given, the global config is used by default.
@@ -340,33 +426,43 @@ module Net
340
426
  open_timeout: 30,
341
427
  idle_response_timeout: 5,
342
428
  sasl_ir: true,
343
- responses_without_block: :silence_deprecation_warning,
429
+ enforce_logindisabled: true,
430
+ responses_without_block: :warn,
431
+ parser_use_deprecated_uidplus_data: :up_to_max_size,
432
+ parser_max_deprecated_uidplus_data_size: 100,
344
433
  ).freeze
345
434
 
346
435
  @global = default.new
347
436
 
348
- version_defaults[0.4] = Config[default.send(:defaults_hash)]
437
+ version_defaults[:default] = Config[default.send(:defaults_hash)]
438
+ version_defaults[:current] = Config[:default]
349
439
 
350
- version_defaults[0] = Config[0.4].dup.update(
440
+ version_defaults[0] = Config[:current].dup.update(
351
441
  sasl_ir: false,
442
+ responses_without_block: :silence_deprecation_warning,
443
+ enforce_logindisabled: false,
444
+ parser_use_deprecated_uidplus_data: true,
445
+ parser_max_deprecated_uidplus_data_size: 10_000,
352
446
  ).freeze
353
447
  version_defaults[0.0] = Config[0]
354
448
  version_defaults[0.1] = Config[0]
355
449
  version_defaults[0.2] = Config[0]
356
450
  version_defaults[0.3] = Config[0]
357
451
 
358
- version_defaults[0.5] = Config[0.4].dup.update(
359
- responses_without_block: :warn,
452
+ version_defaults[0.4] = Config[0.3].dup.update(
453
+ sasl_ir: true,
454
+ parser_max_deprecated_uidplus_data_size: 1000,
360
455
  ).freeze
361
456
 
362
- version_defaults[:default] = Config[0.4]
363
- version_defaults[:current] = Config[0.4]
364
- version_defaults[:next] = Config[0.5]
457
+ version_defaults[0.5] = Config[:current]
365
458
 
366
- version_defaults[0.6] = Config[0.5].dup.update(
459
+ version_defaults[0.6] = Config[0.5].dup.update(
367
460
  responses_without_block: :frozen_dup,
461
+ parser_use_deprecated_uidplus_data: false,
462
+ parser_max_deprecated_uidplus_data_size: 0,
368
463
  ).freeze
369
- version_defaults[:future] = Config[0.6]
464
+ version_defaults[:next] = Config[0.6]
465
+ version_defaults[:future] = Config[:next]
370
466
 
371
467
  version_defaults.freeze
372
468
  end
@@ -186,7 +186,7 @@ module Net
186
186
 
187
187
  # Ensure argument is 'number' or raise DataFormatError
188
188
  def ensure_number(num)
189
- return if valid_number?(num)
189
+ return num if valid_number?(num)
190
190
 
191
191
  msg = "number must be unsigned 32-bit integer: #{num}"
192
192
  raise DataFormatError, msg
@@ -194,7 +194,7 @@ module Net
194
194
 
195
195
  # Ensure argument is 'nz_number' or raise DataFormatError
196
196
  def ensure_nz_number(num)
197
- return if valid_nz_number?(num)
197
+ return num if valid_nz_number?(num)
198
198
 
199
199
  msg = "nz_number must be non-zero unsigned 32-bit integer: #{num}"
200
200
  raise DataFormatError, msg
@@ -202,7 +202,7 @@ module Net
202
202
 
203
203
  # Ensure argument is 'mod_sequence_value' or raise DataFormatError
204
204
  def ensure_mod_sequence_value(num)
205
- return if valid_mod_sequence_value?(num)
205
+ return num if valid_mod_sequence_value?(num)
206
206
 
207
207
  msg = "mod_sequence_value must be unsigned 64-bit integer: #{num}"
208
208
  raise DataFormatError, msg