@@ -1940,28 +1940,8 @@ def uid_expunge(uid_set)
1940
1940
#
1941
1941
# +criteria+ is one or more search keys and their arguments, which may be
1942
1942
# provided as an array or a string.
1943
- # See {"Search criteria"}[rdoc-ref:#search@Search+criteria], below.
1944
- #
1945
- # * When +criteria+ is an array, each member is a +SEARCH+ command argument:
1946
- # * Any SequenceSet sends SequenceSet#valid_string.
1947
- # These types are converted to SequenceSet for validation and encoding:
1948
- # * +Set+
1949
- # * +Range+
1950
- # * <tt>-1</tt> and +:*+ -- both translate to <tt>*</tt>
1951
- # * responds to +#to_sequence_set+
1952
- # * +Array+, when each element is one of the above types, a positive
1953
- # +Integer+, a sequence-set formatted +String+, or a deeply nested
1954
- # +Array+ of these same types.
1955
- # * Any +String+ is sent verbatim when it is a valid \IMAP atom,
1956
- # and encoded as an \IMAP quoted or literal string otherwise.
1957
- # * Any other nested +Array+ is encoded as a parenthesized list, to group
1958
- # multiple search keys (e.g., for use with +OR+ and +NOT+).
1959
- # * Any other +Integer+ (besides <tt>-1</tt>) will be sent as +#to_s+.
1960
- # * +Date+ objects will be encoded as an \IMAP date (see ::encode_date).
1961
- #
1962
- # * When +criteria+ is a string, it will be sent directly to the server
1963
- # <em>without any validation or encoding</em>. *WARNING:* This is
1964
- # vulnerable to injection attacks when external inputs are used.
1943
+ # See {"Argument translation"}[rdoc-ref:#search@Argument+translation]
1944
+ # and {"Search criteria"}[rdoc-ref:#search@Search+criteria], below.
1965
1945
#
1966
1946
# +charset+ is the name of the {registered character
1967
1947
# set}[https://www.iana.org/assignments/character-sets/character-sets.xhtml]
@@ -1972,7 +1952,7 @@ def uid_expunge(uid_set)
1972
1952
#
1973
1953
# Related: #uid_search
1974
1954
#
1975
- # ===== For example:
1955
+ # ==== For example:
1976
1956
#
1977
1957
# p imap.search(["SUBJECT", "hello", "NOT", "SEEN"])
1978
1958
# #=> [1, 6, 7, 8]
@@ -1988,7 +1968,45 @@ def uid_expunge(uid_set)
1988
1968
# # criteria string contains charset arg
1989
1969
# imap.search("CHARSET UTF-8 OR UNSEEN (FLAGGED SUBJECT foo)")
1990
1970
#
1991
- # ===== Search keys
1971
+ # ==== Argument translation
1972
+ #
1973
+ # [When +criteria+ is an Array]
1974
+ # Each member is a +SEARCH+ command argument:
1975
+ # [SequenceSet]
1976
+ # Encoded as an \IMAP +sequence-set+ with SequenceSet#valid_string.
1977
+ # [Set, Range, <tt>-1</tt>, +:*+, responds to +#to_sequence_set+]
1978
+ # Converted to SequenceSet for validation and encoding.
1979
+ # [nested sequence-set +Array+]
1980
+ # When every element in a nested array is one of the above types, a
1981
+ # positive +Integer+, a sequence-set formatted +String+, or a deeply
1982
+ # nested +Array+ of these same types, the array will be converted to
1983
+ # SequenceSet for validation and encoding.
1984
+ # [Any other nested +Array+]
1985
+ # Otherwise, a nested array is encoded as a parenthesized list, to
1986
+ # combine multiple search keys (e.g., for use with +OR+ and +NOT+).
1987
+ # [+String+]
1988
+ # Sent verbatim when it is a valid \IMAP +atom+, and encoded as an \IMAP
1989
+ # +quoted+ or +literal+ string otherwise. Every standard search key
1990
+ # name is a valid \IMAP +atom+ and every standard search key string
1991
+ # argument is an +astring+ which may be encoded as +atom+, +quoted+, or
1992
+ # +literal+.
1993
+ #
1994
+ # *Note:* <tt>*</tt> is not a valid \IMAP +atom+ character. Any string
1995
+ # containing <tt>*</tt> will be encoded as a +quoted+ string, _not_ a
1996
+ # +sequence-set+.
1997
+ # [+Integer+ (except for <tt>-1</tt>)]
1998
+ # Encoded using +#to_s+.
1999
+ # [+Date+]
2000
+ # Encoded as an \IMAP date (see ::encode_date).
2001
+ #
2002
+ # [When +criteria+ is a String]
2003
+ # +criteria+ will be sent directly to the server <em>without any
2004
+ # validation or encoding</em>.
2005
+ #
2006
+ # <em>*WARNING:* This is vulnerable to injection attacks when external
2007
+ # inputs are used.</em>
2008
+ #
2009
+ # ==== Search keys
1992
2010
#
1993
2011
# For full definitions of the standard search +criteria+,
1994
2012
# see [{IMAP4rev1 §6.4.4}[https://www.rfc-editor.org/rfc/rfc3501.html#section-6.4.4]],
@@ -2003,145 +2021,161 @@ def uid_expunge(uid_set)
2003
2021
# arguments. The number and type of arguments is specific to each search
2004
2022
# key.
2005
2023
#
2006
- # +ALL+::
2007
- # Matches every message in the mailbox.
2024
+ # ===== Search keys that match all messages
2008
2025
#
2009
- # (_search-key_ _search-key_...)::
2010
- # Combines one or more _search-key_ arguments to match
2011
- # messages which match all contained search keys. Useful for +OR+, +NOT+,
2012
- # and other search keys with _search-key_ arguments.
2026
+ # [+ALL+]
2027
+ # The default initial key. Matches every message in the mailbox.
2013
2028
#
2014
- # _Note:_ this search key has no label.
2029
+ # [+SAVEDATESUPPORTED+]
2030
+ # Matches every message in the mailbox when the mailbox supports the save
2031
+ # date attribute. Otherwise, it matches no messages.
2015
2032
#
2016
- # +OR+ _search-key_ _search-key_::
2017
- # Matches messages which match either _search-key_ argument.
2033
+ # <em>Requires +SAVEDATE+ capability</em>.
2034
+ # {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2018
2035
#
2019
- # +NOT+ _search-key_::
2020
- # Matches messages which do not match _search-key_.
2036
+ # ===== Sequence set search keys
2021
2037
#
2022
- # _sequence-set_::
2038
+ # [ _sequence-set_]
2023
2039
# Matches messages with message sequence numbers in _sequence-set_.
2024
2040
#
2025
2041
# _Note:_ this search key has no label.
2026
2042
#
2027
2043
# <em>+UIDONLY+ must *not* be enabled.</em>
2028
2044
# {[RFC9586]}[https://www.rfc-editor.org/rfc/rfc9586.html]
2029
2045
#
2030
- # +UID+ _sequence-set_::
2046
+ # [ +UID+ _sequence-set_]
2031
2047
# Matches messages with a UID in _sequence-set_.
2032
2048
#
2033
- # +ANSWERED+::
2034
- # +UNANSWERED+::
2049
+ # ===== Compound search keys
2050
+ #
2051
+ # [(_search-key_ _search-key_...)]
2052
+ # Combines one or more _search-key_ arguments to match
2053
+ # messages which match all contained search keys. Useful for +OR+, +NOT+,
2054
+ # and other search keys with _search-key_ arguments.
2055
+ #
2056
+ # _Note:_ this search key has no label.
2057
+ #
2058
+ # [+OR+ _search-key_ _search-key_]
2059
+ # Matches messages which match either _search-key_ argument.
2060
+ #
2061
+ # [+NOT+ _search-key_]
2062
+ # Matches messages which do not match _search-key_.
2063
+ #
2064
+ # [+FUZZY+ _search-key_]
2065
+ # Uses fuzzy matching for the specified search key.
2066
+ #
2067
+ # <em>Requires <tt>SEARCH=FUZZY</tt> capability.</em>
2068
+ # {[RFC6203]}[https://www.rfc-editor.org/rfc/rfc6203.html#section-6].
2069
+ #
2070
+ # ===== Flags search keys
2071
+ #
2072
+ # [+ANSWERED+, +UNANSWERED+]
2035
2073
# Matches messages with or without the <tt>\\Answered</tt> flag.
2036
- # +DELETED+::
2037
- # +UNDELETED+::
2074
+ # [+DELETED+, +UNDELETED+]
2038
2075
# Matches messages with or without the <tt>\\Deleted</tt> flag.
2039
- # +DRAFT+::
2040
- # +UNDRAFT+::
2076
+ # [+DRAFT+, +UNDRAFT+]
2041
2077
# Matches messages with or without the <tt>\\Draft</tt> flag.
2042
- # +FLAGGED+::
2043
- # +UNFLAGGED+::
2078
+ # [+FLAGGED+, +UNFLAGGED+]
2044
2079
# Matches messages with or without the <tt>\\Flagged</tt> flag.
2045
- # +SEEN+::
2046
- # +UNSEEN+::
2080
+ # [+SEEN+, +UNSEEN+]
2047
2081
# Matches messages with or without the <tt>\\Seen</tt> flag.
2048
- #
2049
- # +KEYWORD+ _keyword_::
2050
- # +UNKEYWORD+ _keyword_::
2082
+ # [+KEYWORD+ _keyword_, +UNKEYWORD+ _keyword_]
2051
2083
# Matches messages with or without the specified _keyword_.
2052
2084
#
2053
- # +BCC+ _substring_::
2054
- # Matches when _substring_ is in the envelope's BCC field.
2055
- # +CC+ _substring_::
2056
- # Matches when _substring_ is in the envelope's CC field.
2057
- # +FROM+ _substring_::
2058
- # Matches when _substring_ is in the envelope's FROM field.
2059
- # +SUBJECT+ _substring_::
2060
- # Matches when _substring_ is in the envelope's SUBJECT field.
2061
- # +TO+ _substring_::
2062
- # Matches when _substring_ is in the envelope's TO field.
2063
- #
2064
- # +HEADER+ _field_ _substring_::
2085
+ # [+RECENT+, +UNRECENT+]
2086
+ # Matches messages with or without the <tt>\\Recent</tt> flag.
2087
+ #
2088
+ # *NOTE:* The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+.
2089
+ # [+NEW+]
2090
+ # Equivalent to <tt>(RECENT UNSEEN)</tt>.
2091
+ #
2092
+ # *NOTE:* The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+.
2093
+ #
2094
+ # ===== Header field substring search keys
2095
+ #
2096
+ # [+BCC+ _substring_]
2097
+ # Matches when _substring_ is in the envelope's +BCC+ field.
2098
+ # [+CC+ _substring_]
2099
+ # Matches when _substring_ is in the envelope's +CC+ field.
2100
+ # [+FROM+ _substring_]
2101
+ # Matches when _substring_ is in the envelope's +FROM+ field.
2102
+ # [+SUBJECT+ _substring_]
2103
+ # Matches when _substring_ is in the envelope's +SUBJECT+ field.
2104
+ # [+TO+ _substring_]
2105
+ # Matches when _substring_ is in the envelope's +TO+ field.
2106
+ #
2107
+ # [+HEADER+ _field_ _substring_]
2065
2108
# Matches when _substring_ is in the specified header _field_.
2066
2109
#
2067
- # +BODY+ _string_::
2110
+ # ===== Body text search keys
2111
+ # [+BODY+ _string_]
2068
2112
# Matches when _string_ is in the body of the message.
2069
2113
# Does not match on header fields.
2070
2114
#
2071
2115
# The server _may_ use flexible matching, rather than simple substring
2072
2116
# matches. For example, this may use stemming or match only full words.
2073
2117
#
2074
- # +TEXT+ _string_::
2118
+ # [ +TEXT+ _string_]
2075
2119
# Matches when _string_ is in the header or body of the message.
2076
2120
#
2077
2121
# The server _may_ use flexible matching, rather than simple substring
2078
2122
# matches. For example, this may use stemming or match only full words.
2079
2123
#
2080
- # +BEFORE+ _date_::
2081
- # +ON+ _date_::
2082
- # +SINCE+ _date_::
2083
- # Matches when the +INTERNALDATE+ is earlier than, on, or later than
2084
- # _date_.
2124
+ # ===== Date/Time search keys
2085
2125
#
2086
- # +SENTBEFORE+ _date_::
2087
- # +SENTON+ _date_::
2088
- # +SENTSINCE+ _date_::
2126
+ # [ +SENTBEFORE+ _date_]
2127
+ # [ +SENTON+ _date_]
2128
+ # [ +SENTSINCE+ _date_]
2089
2129
# Matches when the +Date+ header is earlier than, on, or later than _date_.
2090
2130
#
2091
- # +SMALLER+ _bytes_::
2092
- # +LARGER+ _bytes_::
2093
- # Matches when +RFC822.SIZE+ is smaller/larger than _bytes_.
2094
- #
2095
- # ====== Removed from +IMAP4rev2+
2096
- #
2097
- # The <tt>\\Recent</tt> flag has been removed from +IMAP4rev2+. So these
2098
- # search keys require the +IMAP4rev1+ capability.
2131
+ # [+BEFORE+ _date_]
2132
+ # [+ON+ _date_]
2133
+ # [+SINCE+ _date_]
2134
+ # Matches when the +INTERNALDATE+ is earlier than, on, or later than
2135
+ # _date_.
2099
2136
#
2100
- # +RECENT+::
2101
- # +UNRECENT+::
2102
- # Matches messages with or without the <tt>\\Recent</tt> flag .
2137
+ # [+OLDER+ _interval_]
2138
+ # [+YOUNGER+ _interval_]
2139
+ # Matches when the +INTERNALDATE+ is more/less than _interval_ seconds ago .
2103
2140
#
2104
- # +NEW+::
2105
- # Equivalent to <tt>(RECENT UNSEEN)</tt>.
2141
+ # <em>Requires +WITHIN+ capability</em>.
2142
+ # {[RFC5032]}[https://www.rfc-editor.org/rfc/rfc5032.html]
2106
2143
#
2107
- # ====== Extension search keys
2144
+ # [+SAVEDBEFORE+ _date_]
2145
+ # [+SAVEDON+ _date_]
2146
+ # [+SAVEDSINCE+ _date_]
2147
+ # Matches when the save date is earlier than, on, or later than _date_.
2108
2148
#
2109
- # The search keys described below are defined by standard \IMAP extensions.
2149
+ # <em>Requires +SAVEDATE+ capability.</em>
2150
+ # {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2110
2151
#
2111
- # +OLDER+ _interval_::
2112
- # +YOUNGER+ _interval_::
2113
- # Matches when +INTERNALDATE+ is more/less than _interval_ seconds ago.
2152
+ # ===== Other message attribute search keys
2114
2153
#
2115
- # <em>Requires the +WITHIN+ capability</em>.
2116
- # {[RFC5032]}[https://www.rfc-editor.org/rfc/rfc5032.html]
2154
+ # [+SMALLER+ _bytes_]
2155
+ # [+LARGER+ _bytes_]
2156
+ # Matches when +RFC822.SIZE+ is smaller or larger than _bytes_.
2117
2157
#
2118
- # +ANNOTATION+ _entry_ _attr_ _value_::
2158
+ # [ +ANNOTATION+ _entry_ _attr_ _value_]
2119
2159
# Matches messages that have annotations with entries matching _entry_,
2120
2160
# attributes matching _attr_, and _value_ in the attribute's values.
2121
2161
#
2122
- # <em>Requires the +ANNOTATE-EXPERIMENT-1+ capability</em>.
2162
+ # <em>Requires +ANNOTATE-EXPERIMENT-1+ capability</em>.
2123
2163
# {[RFC5257]}[https://www.rfc-editor.org/rfc/rfc5257.html].
2124
2164
#
2125
- # +FILTER+ _filter_::
2165
+ # [ +FILTER+ _filter_]
2126
2166
# References a _filter_ that is stored on the server and matches all
2127
2167
# messages which would be matched by that filter's search criteria.
2128
2168
#
2129
- # <em>Requires the +FILTERS+ capability</em>.
2169
+ # <em>Requires +FILTERS+ capability</em>.
2130
2170
# {[RFC5466]}[https://www.rfc-editor.org/rfc/rfc5466.html#section-3.1]
2131
2171
#
2132
- # +FUZZY+ _search-key_::
2133
- # Uses fuzzy matching for the specified search key.
2134
- #
2135
- # <em>Requires the <tt>SEARCH=FUZZY</tt> capability.</em>
2136
- # {[RFC6203]}[https://www.rfc-editor.org/rfc/rfc6203.html#section-6].
2137
- #
2138
- # +MODSEQ+ _modseq_::
2172
+ # [+MODSEQ+ _modseq_]
2139
2173
# Matches when +MODSEQ+ is greater than or equal to _modseq_.
2140
2174
#
2141
- # <em>Requires the +CONDSTORE+ capability</em>.
2175
+ # <em>Requires +CONDSTORE+ capability</em>.
2142
2176
# {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.5].
2143
2177
#
2144
- # +MODSEQ+ _entry_ _entry-type_ _modseq_::
2178
+ # [ +MODSEQ+ _entry_ _entry-type_ _modseq_]
2145
2179
# Matches when a specific metadata _entry_ has been updated since
2146
2180
# _modseq_.
2147
2181
#
@@ -2150,33 +2184,18 @@ def uid_expunge(uid_set)
2150
2184
# <tt>\\</tt> prefix. _entry-type_ can be one of <tt>"shared"</tt>,
2151
2185
# <tt>"priv"</tt> (private), or <tt>"all"</tt>.
2152
2186
#
2153
- # <em>Requires the +CONDSTORE+ capability</em>.
2187
+ # <em>Requires +CONDSTORE+ capability</em>.
2154
2188
# {[RFC7162]}[https://www.rfc-editor.org/rfc/rfc7162.html#section-3.1.5].
2155
2189
#
2156
- # +EMAILID+ _objectid_::
2157
- # +THREADID+ _objectid_::
2190
+ # [ +EMAILID+ _objectid_]
2191
+ # [ +THREADID+ _objectid_]
2158
2192
# Matches when +EMAILID+/+THREADID+ is equal to _objectid_
2159
2193
# (substring matches are not supported).
2160
2194
#
2161
- # <em>Requires the +OBJECTID+ capability</em>.
2195
+ # <em>Requires +OBJECTID+ capability</em>.
2162
2196
# {[RFC8474]}[https://www.rfc-editor.org/rfc/rfc8474.html#section-6]
2163
2197
#
2164
- # +SAVEDATESUPPORTED+::
2165
- # Matches every message in the mailbox when the mailbox supports the save
2166
- # date attribute. Otherwise, it matches no messages.
2167
- #
2168
- # <em>Requires the +SAVEDATE+ capability</em>.
2169
- # {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2170
- #
2171
- # +SAVEDBEFORE+ _date_::
2172
- # +SAVEDON+ _date_::
2173
- # +SAVEDSINCE+ _date_::
2174
- # Matches when the save date is earlier than, on, or later than _date_.
2175
- #
2176
- # <em>Requires the +SAVEDATE+ capability.</em>
2177
- # {[RFC8514]}[https://www.rfc-editor.org/rfc/rfc8514.html#section-4.3]
2178
- #
2179
- # ===== Capabilities
2198
+ # ==== Capabilities
2180
2199
#
2181
2200
# If CONDSTORE[https://www.rfc-editor.org/rfc/rfc7162.html] is supported
2182
2201
# and enabled for the selected mailbox, a non-empty SearchResult will
0 commit comments