rfc4731.IMAP4_Extension_to_SEARCH_command.txt 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. Network Working Group A. Melnikov
  2. Request for Comments: 4731 Isode Ltd
  3. Category: Standards Track D. Cridland
  4. Inventure Systems Ltd
  5. November 2006
  6. IMAP4 Extension to SEARCH Command for Controlling
  7. What Kind of Information Is Returned
  8. Status of This Memo
  9. This document specifies an Internet standards track protocol for the
  10. Internet community, and requests discussion and suggestions for
  11. improvements. Please refer to the current edition of the "Internet
  12. Official Protocol Standards" (STD 1) for the standardization state
  13. and status of this protocol. Distribution of this memo is unlimited.
  14. Copyright Notice
  15. Copyright (C) The IETF Trust (2006).
  16. Abstract
  17. This document extends IMAP (RFC 3501) SEARCH and UID SEARCH commands
  18. with several result options, which can control what kind of
  19. information is returned. The following result options are defined:
  20. minimal value, maximal value, all found messages, and number of found
  21. messages.
  22. Table of Contents
  23. 1. Introduction ....................................................2
  24. 2. Conventions Used in This Document ...............................2
  25. 3. IMAP Protocol Changes ...........................................2
  26. 3.1. New SEARCH/UID SEARCH Result Options .......................2
  27. 3.2. Interaction with CONDSTORE extension .......................4
  28. 4. Formal Syntax ...................................................5
  29. 5. Security Considerations .........................................6
  30. 6. IANA Considerations .............................................6
  31. 7. Normative References ............................................6
  32. 8. Acknowledgments .................................................6
  33. Melnikov & Cridland Standards Track [Page 1]
  34. RFC 4731 IMAP4 Extension to SEARCH November 2006
  35. 1. Introduction
  36. [IMAPABNF] extended SEARCH and UID SEARCH commands with result
  37. specifiers (also known as result options), which can control what
  38. kind of information is returned.
  39. A server advertising the ESEARCH capability supports the following
  40. result options: minimal value, maximal value, all found messages,
  41. and number of found messages. These result options allow clients to
  42. get SEARCH results in more convenient forms, while also saving
  43. bandwidth required to transport the results, for example, by finding
  44. the first unseen message or returning the number of unseen or deleted
  45. messages. Also, when a single MIN or a single MAX result option is
  46. specified, servers can optimize execution of SEARCHes.
  47. 2. Conventions Used in This Document
  48. In examples, "C:" and "S:" indicate lines sent by the client and
  49. server, respectively.
  50. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  51. "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  52. document are to be interpreted as described in RFC 2119 [KEYWORDS].
  53. 3. IMAP Protocol Changes
  54. 3.1. New SEARCH/UID SEARCH Result Options
  55. The SEARCH/UID SEARCH commands are extended to allow for the
  56. following result options:
  57. MIN
  58. Return the lowest message number/UID that satisfies the SEARCH
  59. criteria.
  60. If the SEARCH results in no matches, the server MUST NOT
  61. include the MIN result option in the ESEARCH response; however,
  62. it still MUST send the ESEARCH response.
  63. MAX
  64. Return the highest message number/UID that satisfies the SEARCH
  65. criteria.
  66. If the SEARCH results in no matches, the server MUST NOT
  67. include the MAX result option in the ESEARCH response; however,
  68. it still MUST send the ESEARCH response.
  69. Melnikov & Cridland Standards Track [Page 2]
  70. RFC 4731 IMAP4 Extension to SEARCH November 2006
  71. ALL
  72. Return all message numbers/UIDs that satisfy the SEARCH
  73. criteria. Unlike regular (unextended) SEARCH, the messages are
  74. always returned using the sequence-set syntax. A sequence-set
  75. representation may be more compact and can be used as is in a
  76. subsequent command that accepts sequence-set. Note, the client
  77. MUST NOT assume that messages/UIDs will be listed in any
  78. particular order.
  79. If the SEARCH results in no matches, the server MUST NOT
  80. include the ALL result option in the ESEARCH response; however,
  81. it still MUST send the ESEARCH response.
  82. COUNT
  83. Return number of the messages that satisfy the SEARCH criteria.
  84. This result option MUST always be included in the ESEARCH
  85. response.
  86. If one or more result options described above are specified, the
  87. extended SEARCH command MUST return a single ESEARCH response
  88. [IMAPABNF], instead of the SEARCH response.
  89. An extended UID SEARCH command MUST cause an ESEARCH response with
  90. the UID indicator present.
  91. Note that future extensions to this document can allow servers to
  92. return multiple ESEARCH responses for a single extended SEARCH
  93. command. These extensions will have to describe how results from
  94. multiple ESEARCH responses are to be amalgamated.
  95. If the list of result options is empty, that requests the server to
  96. return an ESEARCH response instead of the SEARCH response. This is
  97. equivalent to "(ALL)".
  98. Example: C: A282 SEARCH RETURN (MIN COUNT) FLAGGED
  99. SINCE 1-Feb-1994 NOT FROM "Smith"
  100. S: * ESEARCH (TAG "A282") MIN 2 COUNT 3
  101. S: A282 OK SEARCH completed
  102. Example: C: A283 SEARCH RETURN () FLAGGED
  103. SINCE 1-Feb-1994 NOT FROM "Smith"
  104. S: * ESEARCH (TAG "A283") ALL 2,10:11
  105. S: A283 OK SEARCH completed
  106. The following example demonstrates finding the first unseen message
  107. as returned in the UNSEEN response code on a successful SELECT
  108. command:
  109. Melnikov & Cridland Standards Track [Page 3]
  110. RFC 4731 IMAP4 Extension to SEARCH November 2006
  111. Example: C: A284 SEARCH RETURN (MIN) UNSEEN
  112. S: * ESEARCH (TAG "A284") MIN 4
  113. S: A284 OK SEARCH completed
  114. The following example demonstrates that if the ESEARCH UID indicator
  115. is present, all data in the ESEARCH response is referring to UIDs;
  116. for example, the MIN result specifier will be followed by a UID.
  117. Example: C: A285 UID SEARCH RETURN (MIN MAX) 1:5000
  118. S: * ESEARCH (TAG "A285") UID MIN 7 MAX 3800
  119. S: A285 OK SEARCH completed
  120. The following example demonstrates returning the number of deleted
  121. messages:
  122. Example: C: A286 SEARCH RETURN (COUNT) DELETED
  123. S: * ESEARCH (TAG "A286") COUNT 15
  124. S: A286 OK SEARCH completed
  125. 3.2. Interaction with CONDSTORE extension
  126. When the server supports both the ESEARCH and the CONDSTORE
  127. [CONDSTORE] extension, and the client requests one or more result
  128. option described in section 3.1 together with the MODSEQ search
  129. criterion in the same SEARCH/UID SEARCH command, then the server MUST
  130. return the ESEARCH response containing the MODSEQ result option
  131. (described in the following paragraph) instead of the extended SEARCH
  132. response described in section 3.5 of [CONDSTORE].
  133. If the SEARCH/UID SEARCH command contained a single MIN or MAX result
  134. option, the MODSEQ result option contains the mod-sequence for the
  135. found message. If the SEARCH/UID SEARCH command contained both MIN
  136. and MAX result options and no ALL/COUNT option, the MODSEQ result
  137. option contains the highest mod-sequence for the two returned
  138. messages. Otherwise the MODSEQ result option contains the highest
  139. mod-sequence for all messages being returned.
  140. Example: The following example demonstrates how Example 15 from
  141. [CONDSTORE] would look in the presence of one or more result option:
  142. C: a1 SEARCH RETURN (MIN) MODSEQ "/flags/\\draft"
  143. all 620162338
  144. S: * ESEARCH (TAG "a1") MIN 2 MODSEQ 917162488
  145. S: a1 OK Search complete
  146. C: a2 SEARCH RETURN (MAX) MODSEQ "/flags/\\draft"
  147. all 620162338
  148. S: * ESEARCH (TAG "a2") MAX 23 MODSEQ 907162321
  149. Melnikov & Cridland Standards Track [Page 4]
  150. RFC 4731 IMAP4 Extension to SEARCH November 2006
  151. S: a2 OK Search complete
  152. C: a3 SEARCH RETURN (MIN MAX) MODSEQ "/flags/\\draft"
  153. all 620162338
  154. S: * ESEARCH (TAG "a3") MIN 2 MAX 23 MODSEQ 917162488
  155. S: a3 OK Search complete
  156. C: a4 SEARCH RETURN (MIN COUNT) MODSEQ "/flags/\\draft"
  157. all 620162338
  158. S: * ESEARCH (TAG "a4") MIN 2 COUNT 10 MODSEQ 917162500
  159. S: a4 OK Search complete
  160. 4. Formal Syntax
  161. The following syntax specification uses the Augmented Backus-Naur
  162. Form (ABNF) notation as specified in [ABNF].
  163. Non-terminals referenced but not defined below are as defined by
  164. [IMAP4], [CONDSTORE], or [IMAPABNF].
  165. Except as noted otherwise, all alphabetic characters are case-
  166. insensitive. The use of upper or lowercase characters to define
  167. token strings is for editorial clarity only. Implementations MUST
  168. accept these strings in a case-insensitive fashion.
  169. capability =/ "ESEARCH"
  170. search-return-data = "MIN" SP nz-number /
  171. "MAX" SP nz-number /
  172. "ALL" SP sequence-set /
  173. "COUNT" SP number
  174. ;; conforms to the generic
  175. ;; search-return-data syntax defined
  176. ;; in [IMAPABNF]
  177. search-return-opt = "MIN" / "MAX" / "ALL" / "COUNT"
  178. ;; conforms to generic search-return-opt
  179. ;; syntax defined in [IMAPABNF]
  180. When the CONDSTORE [CONDSTORE] IMAP extension is also supported,
  181. the ABNF is updated as follows:
  182. search-return-data =/ "MODSEQ" SP mod-sequence-value
  183. ;; mod-sequence-value is defined
  184. ;; in [CONDSTORE]
  185. Melnikov & Cridland Standards Track [Page 5]
  186. RFC 4731 IMAP4 Extension to SEARCH November 2006
  187. 5. Security Considerations
  188. In the general case, the IMAP SEARCH/UID SEARCH commands can be CPU
  189. and/or IO intensive, and are seen by some as a potential attack point
  190. for denial of service attacks, so some sites/implementations even
  191. disable them entirely. This is quite unfortunate, as SEARCH command
  192. is one of the best examples demonstrating IMAP advantage over POP3.
  193. The ALL and COUNT return options don't change how SEARCH is working
  194. internally; they only change how information about found messages is
  195. returned. MIN and MAX SEARCH result options described in this
  196. document can lighten the load on IMAP servers that choose to optimize
  197. SEARCHes containing only one or both of them.
  198. It is believed that this extension doesn't raise any additional
  199. security concerns not already discussed in [IMAP4].
  200. 6. IANA Considerations
  201. IMAP4 capabilities are registered by publishing a standards track RFC
  202. or an IESG-approved experimental RFC. The registry is currently
  203. located at <http://www.iana.org/assignments/imap4-capabilities>.
  204. This document defines the ESEARCH IMAP capability, which IANA added
  205. to the registry.
  206. 7. Normative References
  207. [KEYWORDS] Bradner, S., "Key words for use in RFCs to Indicate
  208. Requirement Levels", BCP 14, RFC 2119, March 1997.
  209. [IMAP4] Crispin, M., "INTERNET MESSAGE ACCESS PROTOCOL - VERSION
  210. 4rev1", RFC 3501, March 2003.
  211. [ABNF] Crocker, D. (Ed.) and P. Overell , "Augmented BNF for
  212. Syntax Specifications: ABNF", RFC 4234, October 2005.
  213. [IMAPABNF] Melnikov, A. and C. Daboo, "Collected Extensions to IMAP4
  214. ABNF", RFC 4466, April 2006..
  215. [CONDSTORE] Melnikov, A. and S. Hole, "IMAP Extension for Conditional
  216. STORE", RFC 4551, June 2006.
  217. 8. Acknowledgments
  218. Thanks to Michael Wener, Arnt Gulbrandsen, Cyrus Daboo, Mark Crispin,
  219. and Pete Maclean for comments and corrections.
  220. Melnikov & Cridland Standards Track [Page 6]
  221. RFC 4731 IMAP4 Extension to SEARCH November 2006
  222. Authors' Addresses
  223. Alexey Melnikov
  224. Isode Limited
  225. 5 Castle Business Village
  226. 36 Station Road
  227. Hampton, Middlesex, TW12 2BX
  228. UK
  229. EMail: Alexey.Melnikov@isode.com
  230. Dave A. Cridland
  231. Inventure Systems Limited
  232. EMail: dave.cridland@inventuresystems.co.uk
  233. URL: http://invsys.co.uk/dave/
  234. Melnikov & Cridland Standards Track [Page 7]
  235. RFC 4731 IMAP4 Extension to SEARCH November 2006
  236. Full Copyright Statement
  237. Copyright (C) The IETF Trust (2006).
  238. This document is subject to the rights, licenses and restrictions
  239. contained in BCP 78, and except as set forth therein, the authors
  240. retain all their rights.
  241. This document and the information contained herein are provided on an
  242. "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
  243. OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY, THE IETF TRUST,
  244. AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES,
  245. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT
  246. THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY
  247. IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
  248. PURPOSE.
  249. Intellectual Property
  250. The IETF takes no position regarding the validity or scope of any
  251. Intellectual Property Rights or other rights that might be claimed to
  252. pertain to the implementation or use of the technology described in
  253. this document or the extent to which any license under such rights
  254. might or might not be available; nor does it represent that it has
  255. made any independent effort to identify any such rights. Information
  256. on the procedures with respect to rights in RFC documents can be
  257. found in BCP 78 and BCP 79.
  258. Copies of IPR disclosures made to the IETF Secretariat and any
  259. assurances of licenses to be made available, or the result of an
  260. attempt made to obtain a general license or permission for the use of
  261. such proprietary rights by implementers or users of this
  262. specification can be obtained from the IETF on-line IPR repository at
  263. http://www.ietf.org/ipr.
  264. The IETF invites any interested party to bring to its attention any
  265. copyrights, patents or patent applications, or other proprietary
  266. rights that may cover technology that may be required to implement
  267. this standard. Please address the information to the IETF at
  268. ietf-ipr@ietf.org.
  269. Acknowledgement
  270. Funding for the RFC Editor function is currently provided by the
  271. Internet Society.
  272. Melnikov & Cridland Standards Track [Page 8]