net-imap 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- 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 +10 -0
- data/lib/net/imap/response_parser.rb +608 -352
- data/lib/net/imap/sasl/authenticators.rb +2 -2
- data/lib/net/imap/sasl/xoauth2_authenticator.rb +1 -1
- data/lib/net/imap.rb +22 -24
- 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: e933100b505623a478f75c60fa9daab5da7a67c0e68a5b0cf83db20e4a362f65
|
4
|
+
data.tar.gz: 79e288f7011385db37f53be45d801cc4fc96b2ba5a08db9c3b7b0bed462989d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4d1fa03ef8db7e5311437c04ee11d4f22017d1a289e63eb8c9c0a64b0816722cb68793c92313ace4b738675eb7bad091007e914c9b381e1e61df35a5dd12ccd
|
7
|
+
data.tar.gz: 6532ed39b47bc4fa70be3430d64f385c19a07087ee5c223a066ce42b00c77d5c99661d78a32347e32475175b8431fbabfcb1b8c351b9fb9b931ff5d859e25f87
|
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
|
@@ -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
|