net-imap 0.3.9 → 0.3.10
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/lib/net/imap/errors.rb +20 -0
- data/lib/net/imap.rb +31 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cb2a06dab230abb1358956fd53b2bdf4235a5443ab81d2e4d95df1d253fb4618
|
|
4
|
+
data.tar.gz: df7e4bf879551b5dfde3affca7c391d8fb2b2d6457247bb06567c4500e7c4a81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 180b80a10c10cb1bfc5267e665d256b7c551260cc7069ecebfeaa0673f1a09b552284f506e0b25e3dbd9bbb75a0d5bf9501c8428ba3a645ff163326cf2215a82
|
|
7
|
+
data.tar.gz: b7f47f69d736ba0586d910154d2a94981d12ddcf5db9f95b4ec9d4909d463405ee09c3073dc7060825d66e028edbe269138d41697faa99a09128750b13455f6c
|
data/Gemfile
CHANGED
data/lib/net/imap/errors.rb
CHANGED
|
@@ -81,7 +81,27 @@ module Net
|
|
|
81
81
|
class ByeResponseError < ResponseError
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
+
# Error raised when the server sends an invalid response.
|
|
85
|
+
#
|
|
86
|
+
# This is different from UnknownResponseError: the response has been
|
|
87
|
+
# rejected. Although it may be parsable, the server is forbidden from
|
|
88
|
+
# sending it in the current context. The client should automatically
|
|
89
|
+
# disconnect, abruptly (without logout).
|
|
90
|
+
#
|
|
91
|
+
# Note that InvalidResponseError does not inherit from ResponseError: it
|
|
92
|
+
# can be raised before the response is fully parsed. A related
|
|
93
|
+
# ResponseParseError or ResponseError may be the #cause.
|
|
94
|
+
class InvalidResponseError < Error
|
|
95
|
+
end
|
|
96
|
+
|
|
84
97
|
# Error raised upon an unknown response from the server.
|
|
98
|
+
#
|
|
99
|
+
# This is different from InvalidResponseError: the response may be a
|
|
100
|
+
# valid extension response and the server may be allowed to send it in
|
|
101
|
+
# this context, but Net::IMAP either does not know how to parse it or
|
|
102
|
+
# how to handle it. This could result from enabling unknown or
|
|
103
|
+
# unhandled extensions. The connection may still be usable,
|
|
104
|
+
# but—depending on context—it may be prudent to disconnect.
|
|
85
105
|
class UnknownResponseError < ResponseError
|
|
86
106
|
end
|
|
87
107
|
|
data/lib/net/imap.rb
CHANGED
|
@@ -739,7 +739,7 @@ module Net
|
|
|
739
739
|
# * {Character sets}[https://www.iana.org/assignments/character-sets/character-sets.xhtml]
|
|
740
740
|
#
|
|
741
741
|
class IMAP < Protocol
|
|
742
|
-
VERSION = "0.3.
|
|
742
|
+
VERSION = "0.3.10"
|
|
743
743
|
|
|
744
744
|
autoload :ResponseReader, File.expand_path("imap/response_reader", __dir__)
|
|
745
745
|
|
|
@@ -1014,8 +1014,11 @@ module Net
|
|
|
1014
1014
|
# unsolicited untagged response immeditely _after_ #starttls completes.
|
|
1015
1015
|
#
|
|
1016
1016
|
def starttls(options = {}, verify = true)
|
|
1017
|
-
|
|
1017
|
+
handled = false
|
|
1018
|
+
error = nil
|
|
1019
|
+
ok = send_command("STARTTLS") do |resp|
|
|
1018
1020
|
if resp.kind_of?(TaggedResponse) && resp.name == "OK"
|
|
1021
|
+
handled = true
|
|
1019
1022
|
begin
|
|
1020
1023
|
# for backward compatibility
|
|
1021
1024
|
certs = options.to_str
|
|
@@ -1024,7 +1027,21 @@ module Net
|
|
|
1024
1027
|
end
|
|
1025
1028
|
start_tls_session(options)
|
|
1026
1029
|
end
|
|
1030
|
+
rescue Exception => error
|
|
1031
|
+
raise # note that the error backtrace is in the receiver_thread
|
|
1027
1032
|
end
|
|
1033
|
+
if error
|
|
1034
|
+
disconnect
|
|
1035
|
+
raise error
|
|
1036
|
+
end
|
|
1037
|
+
unless handled
|
|
1038
|
+
disconnect
|
|
1039
|
+
raise InvalidResponseError,
|
|
1040
|
+
"STARTTLS handler was bypassed, although server responded %p" % [
|
|
1041
|
+
ok.raw_data.chomp
|
|
1042
|
+
]
|
|
1043
|
+
end
|
|
1044
|
+
ok
|
|
1028
1045
|
end
|
|
1029
1046
|
|
|
1030
1047
|
# :call-seq:
|
|
@@ -2294,6 +2311,7 @@ module Net
|
|
|
2294
2311
|
put_string(" ")
|
|
2295
2312
|
send_data(i, tag)
|
|
2296
2313
|
end
|
|
2314
|
+
guard_against_tagged_response_skipping_handler!(tag)
|
|
2297
2315
|
put_string(CRLF)
|
|
2298
2316
|
if cmd == "LOGOUT"
|
|
2299
2317
|
@logout_command_tag = tag
|
|
@@ -2309,6 +2327,17 @@ module Net
|
|
|
2309
2327
|
end
|
|
2310
2328
|
end
|
|
2311
2329
|
end
|
|
2330
|
+
rescue InvalidResponseError
|
|
2331
|
+
disconnect
|
|
2332
|
+
raise
|
|
2333
|
+
end
|
|
2334
|
+
|
|
2335
|
+
def guard_against_tagged_response_skipping_handler!(tag)
|
|
2336
|
+
return unless (resp = @tagged_responses[tag])&.name&.upcase == "OK"
|
|
2337
|
+
raise(InvalidResponseError,
|
|
2338
|
+
"Server sent tagged 'OK' before command was finished: %p. " \
|
|
2339
|
+
"This could indicate a malicious server or client-side " \
|
|
2340
|
+
"command injection. Disconnecting." % [resp.raw_data.chomp])
|
|
2312
2341
|
end
|
|
2313
2342
|
|
|
2314
2343
|
def generate_tag
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: net-imap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shugo Maeda
|
|
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
130
|
version: '0'
|
|
131
131
|
requirements: []
|
|
132
|
-
rubygems_version:
|
|
132
|
+
rubygems_version: 4.0.3
|
|
133
133
|
specification_version: 4
|
|
134
134
|
summary: Ruby client api for Internet Message Access Protocol
|
|
135
135
|
test_files: []
|