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.
- checksums.yaml +4 -4
- data/BSDL +22 -0
- data/COPYING +56 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +3 -22
- data/README.md +25 -8
- data/Rakefile +0 -7
- data/docs/styles.css +72 -23
- data/lib/net/imap/authenticators.rb +26 -57
- data/lib/net/imap/command_data.rb +74 -54
- data/lib/net/imap/config/attr_accessors.rb +75 -0
- data/lib/net/imap/config/attr_inheritance.rb +90 -0
- data/lib/net/imap/config/attr_type_coercion.rb +61 -0
- data/lib/net/imap/config.rb +470 -0
- data/lib/net/imap/data_encoding.rb +18 -6
- data/lib/net/imap/data_lite.rb +226 -0
- data/lib/net/imap/deprecated_client_options.rb +142 -0
- data/lib/net/imap/errors.rb +27 -35
- data/lib/net/imap/esearch_result.rb +180 -0
- data/lib/net/imap/fetch_data.rb +597 -0
- data/lib/net/imap/flags.rb +1 -1
- data/lib/net/imap/response_data.rb +250 -440
- data/lib/net/imap/response_parser/parser_utils.rb +245 -0
- data/lib/net/imap/response_parser.rb +1873 -1210
- data/lib/net/imap/sasl/anonymous_authenticator.rb +69 -0
- data/lib/net/imap/sasl/authentication_exchange.rb +139 -0
- data/lib/net/imap/sasl/authenticators.rb +122 -0
- data/lib/net/imap/sasl/client_adapter.rb +123 -0
- data/lib/net/imap/{authenticators/cram_md5.rb → sasl/cram_md5_authenticator.rb} +24 -14
- data/lib/net/imap/sasl/digest_md5_authenticator.rb +342 -0
- data/lib/net/imap/sasl/external_authenticator.rb +83 -0
- data/lib/net/imap/sasl/gs2_header.rb +80 -0
- data/lib/net/imap/{authenticators/login.rb → sasl/login_authenticator.rb} +28 -18
- data/lib/net/imap/sasl/oauthbearer_authenticator.rb +199 -0
- data/lib/net/imap/sasl/plain_authenticator.rb +101 -0
- data/lib/net/imap/sasl/protocol_adapters.rb +101 -0
- data/lib/net/imap/sasl/scram_algorithm.rb +58 -0
- data/lib/net/imap/sasl/scram_authenticator.rb +287 -0
- data/lib/net/imap/sasl/stringprep.rb +6 -66
- data/lib/net/imap/sasl/xoauth2_authenticator.rb +106 -0
- data/lib/net/imap/sasl.rb +148 -44
- data/lib/net/imap/sasl_adapter.rb +20 -0
- data/lib/net/imap/search_result.rb +146 -0
- data/lib/net/imap/sequence_set.rb +1565 -0
- data/lib/net/imap/stringprep/nameprep.rb +70 -0
- data/lib/net/imap/stringprep/saslprep.rb +69 -0
- data/lib/net/imap/stringprep/saslprep_tables.rb +96 -0
- data/lib/net/imap/stringprep/tables.rb +146 -0
- data/lib/net/imap/stringprep/trace.rb +85 -0
- data/lib/net/imap/stringprep.rb +159 -0
- data/lib/net/imap/uidplus_data.rb +244 -0
- data/lib/net/imap/vanished_data.rb +56 -0
- data/lib/net/imap.rb +2109 -924
- data/net-imap.gemspec +7 -8
- data/rakelib/benchmarks.rake +91 -0
- data/rakelib/rfcs.rake +2 -0
- data/rakelib/saslprep.rake +4 -4
- data/rakelib/string_prep_tables_generator.rb +84 -60
- data/sample/net-imap.rb +167 -0
- metadata +45 -47
- data/.github/dependabot.yml +0 -6
- data/.github/workflows/test.yml +0 -38
- data/.gitignore +0 -10
- data/benchmarks/stringprep.yml +0 -65
- data/benchmarks/table-regexps.yml +0 -39
- data/lib/net/imap/authenticators/digest_md5.rb +0 -115
- data/lib/net/imap/authenticators/plain.rb +0 -41
- data/lib/net/imap/authenticators/xoauth2.rb +0 -20
- data/lib/net/imap/response_reader.rb +0 -75
- data/lib/net/imap/sasl/saslprep.rb +0 -55
- data/lib/net/imap/sasl/saslprep_tables.rb +0 -98
- data/lib/net/imap/sasl/stringprep_tables.rb +0 -153
@@ -0,0 +1,180 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Net
|
4
|
+
class IMAP
|
5
|
+
# An "extended search" response (+ESEARCH+). ESearchResult should be
|
6
|
+
# returned (instead of SearchResult) by IMAP#search, IMAP#uid_search,
|
7
|
+
# IMAP#sort, and IMAP#uid_sort under any of the following conditions:
|
8
|
+
#
|
9
|
+
# * Return options were specified for IMAP#search or IMAP#uid_search.
|
10
|
+
# The server must support a search extension which allows
|
11
|
+
# RFC4466[https://www.rfc-editor.org/rfc/rfc4466.html] +return+ options,
|
12
|
+
# such as +ESEARCH+, +PARTIAL+, or +IMAP4rev2+.
|
13
|
+
# * Return options were specified for IMAP#sort or IMAP#uid_sort.
|
14
|
+
# The server must support the +ESORT+ extension
|
15
|
+
# {[RFC5267]}[https://www.rfc-editor.org/rfc/rfc5267.html#section-3].
|
16
|
+
#
|
17
|
+
# *NOTE:* IMAP#search and IMAP#uid_search do not support +ESORT+ yet.
|
18
|
+
# * The server supports +IMAP4rev2+ but _not_ +IMAP4rev1+, or +IMAP4rev2+
|
19
|
+
# has been enabled. +IMAP4rev2+ requires +ESEARCH+ results.
|
20
|
+
#
|
21
|
+
# Note that some servers may claim to support a search extension which
|
22
|
+
# requires an +ESEARCH+ result, such as +PARTIAL+, but still only return a
|
23
|
+
# +SEARCH+ result when +return+ options are specified.
|
24
|
+
#
|
25
|
+
# Some search extensions may result in the server sending ESearchResult
|
26
|
+
# responses after the initiating command has completed. Use
|
27
|
+
# IMAP#add_response_handler to handle these responses.
|
28
|
+
class ESearchResult < Data.define(:tag, :uid, :data)
|
29
|
+
def initialize(tag: nil, uid: nil, data: nil)
|
30
|
+
tag => String | nil; tag = -tag if tag
|
31
|
+
uid => true | false | nil; uid = !!uid
|
32
|
+
data => Array | nil; data ||= []; data.freeze
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
# :call-seq: to_a -> Array of integers
|
37
|
+
#
|
38
|
+
# When either #all or #partial contains a SequenceSet of message sequence
|
39
|
+
# numbers or UIDs, +to_a+ returns that set as an array of integers.
|
40
|
+
#
|
41
|
+
# When both #all and #partial are +nil+, either because the server
|
42
|
+
# returned no results or because +ALL+ and +PARTIAL+ were not included in
|
43
|
+
# the IMAP#search +RETURN+ options, #to_a returns an empty array.
|
44
|
+
#
|
45
|
+
# Note that SearchResult also implements +to_a+, so it can be used without
|
46
|
+
# checking if the server returned +SEARCH+ or +ESEARCH+ data.
|
47
|
+
def to_a; all&.numbers || partial&.to_a || [] end
|
48
|
+
|
49
|
+
##
|
50
|
+
# attr_reader: tag
|
51
|
+
#
|
52
|
+
# The tag string for the command that caused this response to be returned.
|
53
|
+
#
|
54
|
+
# When +nil+, this response was not caused by a particular command.
|
55
|
+
|
56
|
+
##
|
57
|
+
# attr_reader: uid
|
58
|
+
#
|
59
|
+
# Indicates whether #data in this response refers to UIDs (when +true+) or
|
60
|
+
# to message sequence numbers (when +false+).
|
61
|
+
|
62
|
+
##
|
63
|
+
alias uid? uid
|
64
|
+
|
65
|
+
##
|
66
|
+
# attr_reader: data
|
67
|
+
#
|
68
|
+
# Search return data, as an array of <tt>[name, value]</tt> pairs. Most
|
69
|
+
# return data corresponds to a search +return+ option with the same name.
|
70
|
+
#
|
71
|
+
# Note that some return data names may be used more than once per result.
|
72
|
+
#
|
73
|
+
# This data can be more simply retrieved by #min, #max, #all, #count,
|
74
|
+
# #modseq, and other methods.
|
75
|
+
|
76
|
+
# :call-seq: min -> integer or nil
|
77
|
+
#
|
78
|
+
# The lowest message number/UID that satisfies the SEARCH criteria.
|
79
|
+
#
|
80
|
+
# Returns +nil+ when the associated search command has no results, or when
|
81
|
+
# the +MIN+ return option wasn't specified.
|
82
|
+
#
|
83
|
+
# Requires +ESEARCH+ {[RFC4731]}[https://www.rfc-editor.org/rfc/rfc4731.html#section-3.1] or
|
84
|
+
# +IMAP4rev2+ {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.4].
|
85
|
+
def min; data.assoc("MIN")&.last end
|
86
|
+
|
87
|
+
# :call-seq: max -> integer or nil
|
88
|
+
#
|
89
|
+
# The highest message number/UID that satisfies the SEARCH criteria.
|
90
|
+
#
|
91
|
+
# Returns +nil+ when the associated search command has no results, or when
|
92
|
+
# the +MAX+ return option wasn't specified.
|
93
|
+
#
|
94
|
+
# Requires +ESEARCH+ {[RFC4731]}[https://www.rfc-editor.org/rfc/rfc4731.html#section-3.1] or
|
95
|
+
# +IMAP4rev2+ {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.4].
|
96
|
+
def max; data.assoc("MAX")&.last end
|
97
|
+
|
98
|
+
# :call-seq: all -> sequence set or nil
|
99
|
+
#
|
100
|
+
# A SequenceSet containing all message sequence numbers or UIDs that
|
101
|
+
# satisfy the SEARCH criteria.
|
102
|
+
#
|
103
|
+
# Returns +nil+ when the associated search command has no results, or when
|
104
|
+
# the +ALL+ return option was not specified but other return options were.
|
105
|
+
#
|
106
|
+
# Requires +ESEARCH+ {[RFC4731]}[https://www.rfc-editor.org/rfc/rfc4731.html#section-3.1] or
|
107
|
+
# +IMAP4rev2+ {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.4].
|
108
|
+
#
|
109
|
+
# See also: #to_a
|
110
|
+
def all; data.assoc("ALL")&.last end
|
111
|
+
|
112
|
+
# :call-seq: count -> integer or nil
|
113
|
+
#
|
114
|
+
# Returns the number of messages that satisfy the SEARCH criteria.
|
115
|
+
#
|
116
|
+
# Returns +nil+ when the associated search command has no results, or when
|
117
|
+
# the +COUNT+ return option wasn't specified.
|
118
|
+
#
|
119
|
+
# Requires +ESEARCH+ {[RFC4731]}[https://www.rfc-editor.org/rfc/rfc4731.html#section-3.1] or
|
120
|
+
# +IMAP4rev2+ {[RFC9051]}[https://www.rfc-editor.org/rfc/rfc9051.html#section-7.3.4].
|
121
|
+
def count; data.assoc("COUNT")&.last end
|
122
|
+
|
123
|
+
# :call-seq: modseq -> integer or nil
|
124
|
+
#
|
125
|
+
# The highest +mod-sequence+ of all messages being returned.
|
126
|
+
#
|
127
|
+
# Returns +nil+ when the associated search command has no results, or when
|
128
|
+
# the +MODSEQ+ search criterion wasn't specified.
|
129
|
+
#
|
130
|
+
# Note that there is no search +return+ option for +MODSEQ+. It will be
|
131
|
+
# returned whenever the +CONDSTORE+ extension has been enabled. Using the
|
132
|
+
# +MODSEQ+ search criteria will implicitly enable +CONDSTORE+.
|
133
|
+
#
|
134
|
+
# Requires +CONDSTORE+ {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html]
|
135
|
+
# and +ESEARCH+ {[RFC4731]}[https://www.rfc-editor.org/rfc/rfc4731.html#section-3.2].
|
136
|
+
def modseq; data.assoc("MODSEQ")&.last end
|
137
|
+
|
138
|
+
# Returned by ESearchResult#partial.
|
139
|
+
#
|
140
|
+
# Requires +PARTIAL+ {[RFC9394]}[https://www.rfc-editor.org/rfc/rfc9394.html]
|
141
|
+
# or <tt>CONTEXT=SEARCH</tt>/<tt>CONTEXT=SORT</tt>
|
142
|
+
# {[RFC5267]}[https://www.rfc-editor.org/rfc/rfc5267.html]
|
143
|
+
#
|
144
|
+
# See also: #to_a
|
145
|
+
class PartialResult < Data.define(:range, :results)
|
146
|
+
def initialize(range:, results:)
|
147
|
+
range => Range
|
148
|
+
results = SequenceSet[results] unless results.nil?
|
149
|
+
super
|
150
|
+
end
|
151
|
+
|
152
|
+
##
|
153
|
+
# method: range
|
154
|
+
# :call-seq: range -> range
|
155
|
+
|
156
|
+
##
|
157
|
+
# method: results
|
158
|
+
# :call-seq: results -> sequence set or nil
|
159
|
+
|
160
|
+
# Converts #results to an array of integers.
|
161
|
+
#
|
162
|
+
# See also: ESearchResult#to_a.
|
163
|
+
def to_a; results&.numbers || [] end
|
164
|
+
end
|
165
|
+
|
166
|
+
# :call-seq: partial -> PartialResult or nil
|
167
|
+
#
|
168
|
+
# A PartialResult containing a subset of the message sequence numbers or
|
169
|
+
# UIDs that satisfy the SEARCH criteria.
|
170
|
+
#
|
171
|
+
# Requires +PARTIAL+ {[RFC9394]}[https://www.rfc-editor.org/rfc/rfc9394.html]
|
172
|
+
# or <tt>CONTEXT=SEARCH</tt>/<tt>CONTEXT=SORT</tt>
|
173
|
+
# {[RFC5267]}[https://www.rfc-editor.org/rfc/rfc5267.html]
|
174
|
+
#
|
175
|
+
# See also: #to_a
|
176
|
+
def partial; data.assoc("PARTIAL")&.last end
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|