@@ -1930,15 +1930,35 @@ def uid_expunge(uid_set)
19301930 end
19311931
19321932 # Sends a {SEARCH command [IMAP4rev1 §6.4.4]}[https://www.rfc-editor.org/rfc/rfc3501#section-6.4.4]
1933- # to search the mailbox for messages that match the given searching
1934- # criteria, and returns message sequence numbers. +keys+ can either be a
1935- # string holding the entire search string, or a single-dimension array of
1936- # search keywords and arguments.
1937- #
1938- # Returns a SearchResult object. SearchResult inherits from Array (for
1933+ # to search the mailbox for messages that match the given search +criteria+,
1934+ # and returns a SearchResult. SearchResult inherits from Array (for
19391935 # backward compatibility) but adds SearchResult#modseq when the +CONDSTORE+
19401936 # capability has been enabled.
19411937 #
1938+ # +criteria+ is one or more search keys and their arguments, which may be
1939+ # provided as an array or a string.
1940+ #
1941+ # * When +criteria+ is an array, any array members will be converted into
1942+ # a SequenceSet. _NOTE:_ this means that a parenthesized list cannot be
1943+ # sent when +criteria+ is an array.
1944+ #
1945+ # * When +criteria+ is a string, it will be sent directly to the server
1946+ # <em>without any validation</em>. *WARNING:* This is vulnerable to
1947+ # injection attacks when external inputs are used.
1948+ #
1949+ # +charset+ is the name of the {registered character
1950+ # set}[https://www.iana.org/assignments/character-sets/character-sets.xhtml]
1951+ # used by strings in the search +criteria+. When +charset+ isn't specified,
1952+ # either <tt>"US-ASCII"</tt> or <tt"UTF-8"</tt> is assumed, depending on the
1953+ # server's capabilities.
1954+ #
1955+ # _NOTE:_ +charset+ may be sent as part of +criteria+.
1956+ # Do not use the +charset+ argument when it is embedded in +criteria+.
1957+ # For example:
1958+ #
1959+ # imap.search("CHARSET UTF-8 OR UNSEEN FLAGGED")
1960+ # imap.search(%w[CHARSET UTF-8 OR UNSEEN FLAGGED])
1961+ #
19421962 # Related: #uid_search
19431963 #
19441964 # ===== Search criteria
@@ -1989,11 +2009,14 @@ def uid_expunge(uid_set)
19892009 #
19902010 # ===== Capabilities
19912011 #
1992- # If [CONDSTORE[https://www.rfc-editor.org/rfc/rfc7162.html]] is supported
2012+ # When +IMAP4rev2+ is enabled, or when the server supports +IMAP4rev2+ but
2013+ # not +IMAP4rev1+, ESearchResult is always returned instead of SearchResult.
2014+ #
2015+ # If CONDSTORE[https://www.rfc-editor.org/rfc/rfc7162.html] is supported
19932016 # and enabled for the selected mailbox, a non-empty SearchResult will
19942017 # include a +MODSEQ+ value.
19952018 # imap.select("mbox", condstore: true)
1996- # result = imap.search(["SUBJECT", "hi there", "not", "new")
2019+ # result = imap.search(["SUBJECT", "hi there", "not", "new"] )
19972020 # #=> Net::IMAP::SearchResult[1, 6, 7, 8, modseq: 5594]
19982021 # result.modseq # => 5594
19992022 def search ( keys , charset = nil )
@@ -2008,7 +2031,7 @@ def search(keys, charset = nil)
20082031 # backward compatibility) but adds SearchResult#modseq when the +CONDSTORE+
20092032 # capability has been enabled.
20102033 #
2011- # See #search for documentation of search criteria .
2034+ # See #search for documentation of parameters .
20122035 def uid_search ( keys , charset = nil )
20132036 return search_internal ( "UID SEARCH" , keys , charset )
20142037 end
0 commit comments