net-imap 0.4.1 → 0.4.4
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -0
- data/lib/net/imap/errors.rb +20 -0
- data/lib/net/imap/response_data.rb +46 -6
- data/lib/net/imap/response_parser/parser_utils.rb +14 -4
- data/lib/net/imap/response_parser.rb +609 -368
- data/lib/net/imap/sasl/anonymous_authenticator.rb +3 -2
- data/lib/net/imap/sasl/authenticators.rb +2 -2
- data/lib/net/imap/sasl/cram_md5_authenticator.rb +7 -3
- data/lib/net/imap/sasl/digest_md5_authenticator.rb +20 -8
- data/lib/net/imap/sasl/external_authenticator.rb +26 -5
- data/lib/net/imap/sasl/login_authenticator.rb +7 -3
- data/lib/net/imap/sasl/oauthbearer_authenticator.rb +73 -38
- data/lib/net/imap/sasl/plain_authenticator.rb +19 -11
- data/lib/net/imap/sasl/scram_authenticator.rb +19 -10
- data/lib/net/imap/sasl/xoauth2_authenticator.rb +34 -16
- data/lib/net/imap.rb +26 -28
- data/net-imap.gemspec +3 -2
- data/rakelib/benchmarks.rake +98 -0
- metadata +3 -6
- data/benchmarks/generate_parser_benchmarks +0 -52
- data/benchmarks/parser.yml +0 -578
- data/benchmarks/stringprep.yml +0 -65
- data/benchmarks/table-regexps.yml +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da8cb634d9ee1613035c81a25d28ae9f36b3d0985bcb61da9a38aacb87854a5f
|
4
|
+
data.tar.gz: e504b145415da3a025c6f4ab973b212764c75ef4214d0fed485fdb0b17e83752
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cef39a5ac6454ded84c395fb2671df678e17611d7eff42665113c21f955ebcb6ffdf9035dd1e6fdb3de38aa38f43431537ded3d484ffba7d699b478bb8c3e1e
|
7
|
+
data.tar.gz: 23f777092b2940b725685285a6372b56744a9968fcc76872ebf9ef3136fb3665a89a85174dc34636e547b90d8d3a1945627ce79390f10122aadb57b57004f789
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/lib/net/imap/errors.rb
CHANGED
@@ -47,7 +47,27 @@ module Net
|
|
47
47
|
class ByeResponseError < ResponseError
|
48
48
|
end
|
49
49
|
|
50
|
+
# Error raised when the server sends an invalid response.
|
51
|
+
#
|
52
|
+
# This is different from UnknownResponseError: the response has been
|
53
|
+
# rejected. Although it may be parsable, the server is forbidden from
|
54
|
+
# sending it in the current context. The client should automatically
|
55
|
+
# disconnect, abruptly (without logout).
|
56
|
+
#
|
57
|
+
# Note that InvalidResponseError does not inherit from ResponseError: it
|
58
|
+
# can be raised before the response is fully parsed. A related
|
59
|
+
# ResponseParseError or ResponseError may be the #cause.
|
60
|
+
class InvalidResponseError < Error
|
61
|
+
end
|
62
|
+
|
50
63
|
# Error raised upon an unknown response from the server.
|
64
|
+
#
|
65
|
+
# This is different from InvalidResponseError: the response may be a
|
66
|
+
# valid extension response and the server may be allowed to send it in
|
67
|
+
# this context, but Net::IMAP either does not know how to parse it or
|
68
|
+
# how to handle it. This could result from enabling unknown or
|
69
|
+
# unhandled extensions. The connection may still be usable,
|
70
|
+
# but—depending on context—it may be prudent to disconnect.
|
51
71
|
class UnknownResponseError < ResponseError
|
52
72
|
end
|
53
73
|
|
@@ -55,17 +55,54 @@ module Net
|
|
55
55
|
|
56
56
|
# Net::IMAP::IgnoredResponse represents intentionally ignored responses.
|
57
57
|
#
|
58
|
-
# This includes untagged response "NOOP" sent by eg. Zimbra to avoid
|
59
|
-
# clients to close the connection.
|
58
|
+
# This includes untagged response "NOOP" sent by eg. Zimbra to avoid
|
59
|
+
# some clients to close the connection.
|
60
60
|
#
|
61
61
|
# It matches no IMAP standard.
|
62
|
+
class IgnoredResponse < UntaggedResponse
|
63
|
+
end
|
64
|
+
|
65
|
+
# **Note:** This represents an intentionally _unstable_ API. Where
|
66
|
+
# instances of this class are returned, future releases may return a
|
67
|
+
# different (incompatible) object <em>without deprecation or warning</em>.
|
68
|
+
#
|
69
|
+
# Net::IMAP::UnparsedData represents data for unknown response types or
|
70
|
+
# unknown extensions to response types without a well-defined extension
|
71
|
+
# grammar.
|
62
72
|
#
|
63
|
-
|
73
|
+
# See also: UnparsedNumericResponseData
|
74
|
+
class UnparsedData < Struct.new(:unparsed_data)
|
64
75
|
##
|
65
|
-
# method:
|
66
|
-
# :call-seq:
|
76
|
+
# method: unparsed_data
|
77
|
+
# :call-seq: unparsed_data -> string
|
67
78
|
#
|
68
|
-
# The
|
79
|
+
# The unparsed data
|
80
|
+
end
|
81
|
+
|
82
|
+
# **Note:** This represents an intentionally _unstable_ API. Where
|
83
|
+
# instances of this class are returned, future releases may return a
|
84
|
+
# different (incompatible) object <em>without deprecation or warning</em>.
|
85
|
+
#
|
86
|
+
# Net::IMAP::UnparsedNumericResponseData represents data for unhandled
|
87
|
+
# response types with a numeric prefix. See the documentation for #number.
|
88
|
+
#
|
89
|
+
# See also: UnparsedData
|
90
|
+
class UnparsedNumericResponseData < Struct.new(:number, :unparsed_data)
|
91
|
+
##
|
92
|
+
# method: number
|
93
|
+
# :call-seq: number -> integer
|
94
|
+
#
|
95
|
+
# Returns a numeric response data prefix, when available.
|
96
|
+
#
|
97
|
+
# Many response types are prefixed with a non-negative #number. For
|
98
|
+
# message data, #number may represent a sequence number or a UID. For
|
99
|
+
# mailbox data, #number may represent a message count.
|
100
|
+
|
101
|
+
##
|
102
|
+
# method: unparsed_data
|
103
|
+
# :call-seq: unparsed_data -> string
|
104
|
+
#
|
105
|
+
# The unparsed data, not including #number or UntaggedResponse#name.
|
69
106
|
end
|
70
107
|
|
71
108
|
# Net::IMAP::TaggedResponse represents tagged responses.
|
@@ -108,6 +145,9 @@ module Net
|
|
108
145
|
# UntaggedResponse#data when the response type is a "condition" ("OK", "NO",
|
109
146
|
# "BAD", "PREAUTH", or "BYE").
|
110
147
|
class ResponseText < Struct.new(:code, :text)
|
148
|
+
# Used to avoid an allocation when ResponseText is empty
|
149
|
+
EMPTY = new(nil, "").freeze
|
150
|
+
|
111
151
|
##
|
112
152
|
# method: code
|
113
153
|
# :call-seq: code -> ResponseCode or nil
|
@@ -15,6 +15,7 @@ module Net
|
|
15
15
|
|
16
16
|
# we can skip lexer for single character matches, as a shortcut
|
17
17
|
def def_char_matchers(name, char, token)
|
18
|
+
byte = char.ord
|
18
19
|
match_name = name.match(/\A[A-Z]/) ? "#{name}!" : name
|
19
20
|
char = char.dump
|
20
21
|
class_eval <<~RUBY, __FILE__, __LINE__ + 1
|
@@ -27,7 +28,7 @@ module Net
|
|
27
28
|
|
28
29
|
# use token or string peek
|
29
30
|
def peek_#{name}?
|
30
|
-
@token ? @token.symbol == #{token} : @str
|
31
|
+
@token ? @token.symbol == #{token} : @str.getbyte(@pos) == #{byte}
|
31
32
|
end
|
32
33
|
|
33
34
|
# like accept(token_symbols); returns token or nil
|
@@ -35,7 +36,7 @@ module Net
|
|
35
36
|
if @token&.symbol == #{token}
|
36
37
|
#{SHIFT_TOKEN}
|
37
38
|
#{char}
|
38
|
-
elsif !@token && @str
|
39
|
+
elsif !@token && @str.getbyte(@pos) == #{byte}
|
39
40
|
@pos += 1
|
40
41
|
#{char}
|
41
42
|
end
|
@@ -46,7 +47,7 @@ module Net
|
|
46
47
|
if @token&.symbol == #{token}
|
47
48
|
#{SHIFT_TOKEN}
|
48
49
|
#{char}
|
49
|
-
elsif !@token && @str
|
50
|
+
elsif !@token && @str.getbyte(@pos) == #{byte}
|
50
51
|
@pos += 1
|
51
52
|
#{char}
|
52
53
|
else
|
@@ -109,7 +110,6 @@ module Net
|
|
109
110
|
end
|
110
111
|
end
|
111
112
|
RUBY
|
112
|
-
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
@@ -170,6 +170,16 @@ module Net
|
|
170
170
|
@token ||= next_token
|
171
171
|
end
|
172
172
|
|
173
|
+
# like match, without consuming the token
|
174
|
+
def lookahead!(*args)
|
175
|
+
if args.include?((@token ||= next_token)&.symbol)
|
176
|
+
@token
|
177
|
+
else
|
178
|
+
parse_error('unexpected token %s (expected %s)',
|
179
|
+
@token&.symbol, args.join(" or "))
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
173
183
|
def peek_str?(str)
|
174
184
|
assert_no_lookahead if Net::IMAP.debug
|
175
185
|
@str[@pos, str.length] == str
|