idnits 2.17.1 draft-ietf-imapext-sort-15.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- ** It looks like you're using RFC 3978 boilerplate. You should update this to the boilerplate described in the IETF Trust License Policy document (see https://trustee.ietf.org/license-info), which is required now. -- Found old boilerplate from RFC 3667, Section 5.1 on line 815. -- Found old boilerplate from RFC 3978, Section 5.5 on line 851. -- Found old boilerplate from RFC 3979, Section 5, paragraph 1 on line 862. -- Found old boilerplate from RFC 3979, Section 5, paragraph 2 on line 869. -- Found old boilerplate from RFC 3979, Section 5, paragraph 3 on line 875. ** Found boilerplate matching RFC 3979, Section 5, paragraph 1 (on line 862), which is fine, but *also* found old RFC 2026, Section 10.4A text on line 831. ** Found boilerplate matching RFC 3979, Section 5, paragraph 3 (on line 875), which is fine, but *also* found old RFC 2026, Section 10.4B text on line 837. ** The document claims conformance with section 10 of RFC 2026, but uses some RFC 3978/3979 boilerplate. As RFC 3978/3979 replaces section 10 of RFC 2026, you should not claim conformance with it if you have changed to using RFC 3978/3979 boilerplate. ** The document seems to lack an RFC 3978 Section 5.1 IPR Disclosure Acknowledgement -- however, there's a paragraph with a matching beginning. Boilerplate error? ** This document has an original RFC 3978 Section 5.4 Copyright Line, instead of the newer IETF Trust Copyright according to RFC 4748. ** The document seems to lack an RFC 3978 Section 5.4 Reference to BCP 78 -- however, there's a paragraph with a matching beginning. Boilerplate error? ** This document has an original RFC 3978 Section 5.5 Disclaimer, instead of the newer disclaimer which includes the IETF Trust according to RFC 4748. ** The document uses RFC 3667 boilerplate or RFC 3978-like boilerplate instead of verbatim RFC 3978 boilerplate. After 6 May 2005, submission of drafts without verbatim RFC 3978 boilerplate is not accepted. The following non-3978 patterns matched text found in the document. That text should be removed or replaced: By submitting this Internet-Draft, I certify that any applicable patent or other IPR claims of which I am aware have been disclosed, or will be disclosed, and any of which I become aware will be disclosed, in accordance with RFC 3668. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- ** Missing expiration date. The document expiration date should appear on the first and last page. ** The document seems to lack a 1id_guidelines paragraph about the list of Shadow Directories. ** The document is more than 15 pages and seems to lack a Table of Contents. == No 'Intended status' indicated for this document; assuming Proposed Standard == The page length should not exceed 58 lines per page, but there was 1 longer page, the longest (page 1) being 911 lines Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** There are 91 instances of too long lines in the document, the longest one being 6 characters in excess of 72. ** The abstract seems to contain references ([IMAP]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords -- however, there's a paragraph with a matching beginning. Boilerplate error? RFC 2119 keyword, line 116: '... MUST use exactly this algorithm wh...' RFC 2119 keyword, line 127: '...he date and time SHOULD be treated as ...' RFC 2119 keyword, line 128: '...nvalid, the time SHOULD be treated as ...' RFC 2119 keyword, line 129: '...the date and time SHOULD be treated as...' RFC 2119 keyword, line 164: '...d UTF-8 charsets MUST be implemented. ...' (7 more instances...) Miscellaneous warnings: ---------------------------------------------------------------------------- == In addition to RFC 3979, Section 5, paragraph 1 boilerplate, a section with a similar start was also found: The IETF takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on the IETF's procedures with respect to rights in standards-track and standards-related documentation can be found in BCP-11. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementors or users of this specification can be obtained from the IETF Secretariat. == In addition to RFC 3979, Section 5, paragraph 3 boilerplate, a section with a similar start was also found: The IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights which may cover technology that may be required to practice this standard. Please address the information to the IETF Executive Director. == The copyright year in the RFC 3978 Section 5.4 Copyright Line does not match the current year -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (April 2004) is 7287 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Missing reference section? 'IMAP' on line 766 looks like a reference -- Missing reference section? 'IMAP-MODELS' on line 783 looks like a reference -- Missing reference section? 'KEYWORDS' on line 772 looks like a reference -- Missing reference section? 'ABNF' on line 758 looks like a reference -- Missing reference section? 'IMAP-MODEL' on line 115 looks like a reference -- Missing reference section? 'CHARSET' on line 762 looks like a reference -- Missing reference section? 'THREADING' on line 786 looks like a reference -- Missing reference section? 'RFC 2822' on line 367 looks like a reference -- Missing reference section? 'IMAP-I18N' on line 769 looks like a reference -- Missing reference section? 'RFC-2822' on line 776 looks like a reference Summary: 15 errors (**), 0 flaws (~~), 5 warnings (==), 17 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 IMAP Extensions Working Group M. Crispin 3 INTERNET-DRAFT: IMAP SORT K. Murchison 4 Document: internet-drafts/draft-ietf-imapext-sort-15.txt April 2004 6 INTERNET MESSAGE ACCESS PROTOCOL - SORT AND THREAD EXTENSIONS 8 Status of this Memo 10 This document is an Internet-Draft and is in full conformance with 11 all provisions of Section 10 of RFC 2026. 13 Internet-Drafts are working documents of the Internet Engineering 14 Task Force (IETF), its areas, and its working groups. Note that 15 other groups may also distribute working documents as 16 Internet-Drafts. 18 Internet-Drafts are draft documents valid for a maximum of six months 19 and may be updated, replaced, or obsoleted by other documents at any 20 time. It is inappropriate to use Internet-Drafts as reference 21 material or to cite them other than as "work in progress." 23 The list of current Internet-Drafts can be accessed at 24 http://www.ietf.org/ietf/1id-abstracts.txt 26 To view the list Internet-Draft Shadow Directories, see 27 http://www.ietf.org/shadow.html. 29 A revised version of this document will be submitted to the RFC 30 editor as an Informational Document for the Internet Community. 32 A revised version of this draft document will be submitted to the RFC 33 editor as a Proposed Standard for the Internet Community. Discussion 34 and suggestions for improvement are requested, and should be sent to 35 ietf-imapext@IMC.ORG. This document will expire before 7 October 2004. 36 Distribution of this memo is unlimited. 38 Abstract 40 This document describes the base-level server-based sorting and 41 threading extensions to the [IMAP] protocol. These extensions 42 provide substantial performance improvements for IMAP clients which 43 offer sorted and threaded views. 45 1. Introduction 47 The SORT and THREAD extensions to the [IMAP] protocol provide a means 48 of server-based sorting and threading of messages, without requiring 49 that the client download the necessary data to do so itself. This is 50 particularly useful for online clients as described in [IMAP-MODELS]. 52 A server which supports the base-level SORT extension indicates this 53 with a capability name which starts with "SORT". Future, 54 upwards-compatible extensions to the SORT extension will all start 55 with "SORT", indicating support for this base level. 57 A server which supports the THREAD extension indicates this with one 58 or more capability names consisting of "THREAD=" followed by a 59 supported threading algorithm name as described in this document. 60 This provides for future upwards-compatible extensions. 62 2. Terminology 64 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 65 "SHOULD", "SHOULD NOT", "MAY", and "OPTIONAL" in this document are to 66 be interpreted as described in [KEYWORDS]. 68 The word "can" (not "may") is used to refer to a possible 69 circumstance or situation, as opposed to an optional facility of the 70 protocol. 72 "User" is used to refer to a human user, whereas "client" refers to 73 the software being run by the user. 75 In examples, "C:" and "S:" indicate lines sent by the client and 76 server respectively. 78 2.1 Base Subject 80 Subject sorting and threading use the "base subject," which has 81 specific subject artifacts removed. Due to the complexity of these 82 artifacts, the formal syntax for the subject extraction rules is 83 ambiguous. The following procedure is followed to determine the 84 actual "base subject" which is used to sort by subject, using the 85 [ABNF] formal syntax rules described in section 5: 87 (1) Convert any RFC 2047 encoded-words in the subject to 88 UTF-8 as described in "internationalization 89 considerations." Convert all tabs and continuations to 90 space. Convert all multiple spaces to a single space. 92 (2) Remove all trailing text of the subject that matches 93 the subj-trailer ABNF, repeat until no more matches are 94 possible. 96 (3) Remove all prefix text of the subject that matches the 97 subj-leader ABNF. 99 (4) If there is prefix text of the subject that matches the 100 subj-blob ABNF, and removing that prefix leaves a non-empty 101 subj-base, then remove the prefix text. 103 (5) Repeat (3) and (4) until no matches remain. 105 Note: it is possible to defer step (2) until step (6), but this 106 requires checking for subj-trailer in step (4). 108 (6) If the resulting text begins with the subj-fwd-hdr ABNF 109 and ends with the subj-fwd-trl ABNF, remove the 110 subj-fwd-hdr and subj-fwd-trl and repeat from step (2). 112 (7) The resulting text is the "base subject" used in the 113 SORT. 115 All servers and disconnected (as described in [IMAP-MODEL]) clients 116 MUST use exactly this algorithm when sorting by subject. Otherwise 117 there is potential for a user to get inconsistent results based on 118 whether they are running in connected or disconnected mode. 120 2.2 Sent Date 122 As used in this document, the term "sent date" refers to the date and 123 time from the Date: header, adjusted by time zone to normalize to UTC. 124 For example, "31 Dec 2000 16:01:33 -0800" is equivalent to the UTC 125 date and time of "1 Jan 2001 00:01:33 +0000". 127 If the time zone is invalid, the date and time SHOULD be treated as UTC. 128 If the time is also invalid, the time SHOULD be treated as 00:00:00. If 129 there is no valid date or time, the date and time SHOULD be treated as 130 00:00:00 on the earliest possible date. 132 This differs from the date-related criteria in the SEARCH command 133 (described in [IMAP] section 6.4.4), which use just the date and not 134 the time, and are not adjusted by time zone. 136 3. Additional Commands 138 These commands are extension to the [IMAP] base protocol. 140 The section headings are intended to correspond with where they would 141 be located in the main document if they were part of the base 142 specification. 144 BASE.6.4.SORT. SORT Command 146 Arguments: sort program 147 charset specification 148 searching criteria (one or more) 150 Data: untagged responses: SORT 152 Result: OK - sort completed 153 NO - sort error: can't sort that charset or 154 criteria 155 BAD - command unknown or arguments invalid 157 The SORT command is a variant of SEARCH with sorting semantics for 158 the results. Sort has two arguments before the searching criteria 159 argument; a parenthesized list of sort criteria, and the searching 160 charset. 162 The charset argument is mandatory (unlike SEARCH) and indicates 163 the [CHARSET] of the strings that appear in the searching criteria. 164 The US-ASCII and UTF-8 charsets MUST be implemented. All other 165 charsets are optional. 167 There is also a UID SORT command which returns unique identifiers 168 instead of message sequence numbers. Note that there are separate 169 searching criteria for message sequence numbers and UIDs; thus the 170 arguments to UID SORT are interpreted the same as in SORT. This is 171 analogous to the behavior of UID SEARCH, as opposed to UID COPY, UID 172 FETCH, or UID STORE. 174 The SORT command first searches the mailbox for messages that 175 match the given searching criteria using the charset argument for 176 the interpretation of strings in the searching criteria. It then 177 returns the matching messages in an untagged SORT response, sorted 178 according to one or more sort criteria. 180 Sorting is in ascending order. Earlier dates sort before later 181 dates; smaller sizes sort before larger sizes; and strings are 182 sorted according to ascending values established by their 183 collation algorithm (see under "Internationalization 184 Considerations"). 186 If two or more messages exactly match according to the sorting 187 criteria, these messages are sorted according to the order in 188 which they appear in the mailbox. In other words, there is an 189 implicit sort criterion of "sequence number". 191 When multiple sort criteria are specified, the result is sorted in 192 the priority order that the criteria appear. For example, 193 (SUBJECT DATE) will sort messages in order by their base subject 194 text; and for messages with the same base subject text will sort 195 by their sent date. 197 Untagged EXPUNGE responses are not permitted while the server is 198 responding to a SORT command, but are permitted during a UID SORT 199 command. 201 The defined sort criteria are as follows. Refer to the Formal 202 Syntax section for the precise syntactic definitions of the 203 arguments. If the associated RFC-822 header for a particular 204 criterion is absent, it is treated as the empty string. The empty 205 string always collates before non-empty strings. 207 ARRIVAL 208 Internal date and time of the message. This differs from the 209 ON criteria in SEARCH, which uses just the internal date. 211 CC 212 RFC-822 local-part of the first "cc" address. 214 DATE 215 Sent date and time from the Date: header, adjusted by time 216 zone. This differs from the SENTON criteria in SEARCH, which 217 uses just the date and not the time, nor adjusts by time zone. 219 FROM 220 RFC-822 local-part of the first "From" address. 222 REVERSE 223 Followed by another sort criterion, has the effect of that 224 criterion but in reverse (descending) order. 225 Note: REVERSE only reverses a single criterion, and does not 226 affect the implicit "sequence number" sort criterion if all 227 other criteria are identicial. Consequently, a sort of 228 REVERSE SUBJECT is not the same as a reverse ordering of a 229 SUBJECT sort. This can be avoided by use of additional 230 criteria, e.g. SUBJECT DATE vs. REVERSE SUBJECT REVERSE 231 DATE. In general, however, it's better (and faster, if the 232 client has a "reverse current ordering" command) to reverse 233 the results in the client instead of issuing a new SORT. 235 SIZE 236 Size of the message in octets. 238 SUBJECT 239 Base subject text. 241 TO 242 RFC-822 local-part of the first "To" address. 244 Example: C: A282 SORT (SUBJECT) UTF-8 SINCE 1-Feb-1994 245 S: * SORT 2 84 882 246 S: A282 OK SORT completed 247 C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 ALL 248 S: * SORT 5 3 4 1 2 249 S: A283 OK SORT completed 250 C: A284 SORT (SUBJECT) US-ASCII TEXT "not in mailbox" 251 S: * SORT 252 S: A284 OK SORT completed 254 BASE.6.4.THREAD. THREAD Command 256 Arguments: threading algorithm 257 charset specification 258 searching criteria (one or more) 260 Data: untagged responses: THREAD 262 Result: OK - thread completed 263 NO - thread error: can't thread that charset or 264 criteria 265 BAD - command unknown or arguments invalid 267 The THREAD command is a variant of SEARCH with threading semantics 268 for the results. Thread has two arguments before the searching 269 criteria argument; a threading algorithm, and the searching 270 charset. 272 The charset argument is mandatory (unlike SEARCH) and indicates 273 the [CHARSET] of the strings that appear in the searching criteria. 274 The US-ASCII and UTF-8 charsets MUST be implemented. All other 275 charsets are optional. 277 There is also a UID THREAD command which returns unique identifiers 278 instead of message sequence numbers. Note that there are separate 279 searching criteria for message sequence numbers and UIDs; thus the 280 arguments to UID THREAD are interpreted the same as in THREAD. This is 281 analogous to the behavior of UID SEARCH, as opposed to UID COPY, UID 282 FETCH, or UID STORE. 284 The THREAD command first searches the mailbox for messages that 285 match the given searching criteria using the charset argument for 286 the interpretation of strings in the searching criteria. It then 287 returns the matching messages in an untagged THREAD response, 288 threaded according to the specified threading algorithm. 290 All collation is in ascending order. Earlier dates collate before 291 later dates and strings are collated according to ascending values 292 established by their collation algorithm (see under 293 "Internationalization Considerations"). 295 The defined threading algorithms are as follows: 297 ORDEREDSUBJECT 299 The ORDEREDSUBJECT threading algorithm is also referred to as 300 "poor man's threading." The searched messages are sorted by 301 base subject and then by the sent date. The messages are then 302 split into separate threads, with each thread containing 303 messages with the same base subject text. Finally, the threads 304 are sorted by the sent date of the first message in the thread. 306 The first message of each thread are siblings of each other 307 (the "root"). The second message of a thread is the child of 308 the first message, and subsequent messages of the thread are 309 siblings of the second message and hence children of the 310 message at the root. Hence, there are no grandchildren in 311 ORDEREDSUBJECT threading. 313 Note: early drafts of this specification specified 314 that each message in an ORDEREDSUBJECT thread is a child 315 (as opposed to a sibling) of the previous message. This 316 is now deprecated. For compatibility with servers which 317 may still use the old definition, client implementations 318 SHOULD treat descendents of a child as being siblings of 319 that child. 321 This is because the old definition mistakenly indicated 322 that there was a parent/child relationship between 323 successive messages in a thread; when in fact there was 324 only a chronological relationship. In clients which 325 indicate parent/child relationships in a thread tree, 326 this would indicate levels of descent which did not 327 exist. 329 REFERENCES 331 The REFERENCES threading algorithm is based on the [THREADING] 332 algorithm written used in "Netscape Mail and News" versions 2.0 333 through 3.0. This algorithm threads the searched messages by 334 grouping them together in parent/child relationships based on 335 which messages are replies to others. The parent/child 336 relationships are built using two methods: reconstructing a 337 message's ancestry using the references contained within it; 338 and checking the original (not base) subject of a message to 339 see if it is a reply to (or forward of) another message. 341 Note: "Message ID" in the following description refers to a 342 normalized form of the msg-id in [RFC 2822]. The actual 343 text in an RFC 2822 may use quoting, resulting in multiple 344 ways of expressing the same Message ID. Implementations of 345 the REFERENCES threading algorithm MUST normalize any msg-id 346 in order to avoid false non-matches due to differences in 347 quoting. 349 For example, the msg-id 350 <"01KF8JCEOCBS0045PS"@xxx.yyy.com> 351 and the msg-id 352 <01KF8JCEOCBS0045PS@xxx.yyy.com> 353 MUST be interpreted as being the same Message ID. 355 The references used for reconstructing a message's ancestry are 356 found using the following rules: 358 If a message contains a References header line, then use the 359 Message IDs in the References header line as the references. 361 If a message does not contain a References header line, or 362 the References header line does not contain any valid 363 Message IDs, then use the first (if any) valid Message ID 364 found in the In-Reply-To header line as the only reference 365 (parent) for this message. 367 Note: Although [RFC 2822] permits multiple Message IDs in 368 the In-Reply-To header, in actual practice this 369 discipline has not been followed. For example, 370 In-Reply-To headers have been observed with message 371 addresses after the Message ID, and there are no good 372 heuristics for software to determine the difference. 373 This is not a problem with the References header however. 375 If a message does not contain an In-Reply-To header line, or 376 the In-Reply-To header line does not contain a valid Message 377 ID, then the message does not have any references (NIL). 379 A message is considered to be a reply or forward if the base 380 subject extraction rules, applied to the original subject, 381 remove any of the following: a subj-refwd, a "(fwd)" 382 subj-trailer, or a subj-fwd-hdr and subj-fwd-trl. 384 The REFERENCES algorithm is significantly more complex than 385 ORDEREDSUBJECT and consists of six main steps. These steps are 386 outlined in detail below. 388 (1) For each searched message: 390 (A) Using the Message IDs in the message's references, link 391 the corresponding messages (those whose Message-ID header 392 line contains the given reference Message ID) together as 393 parent/child. Make the first reference the parent of the 394 second (and the second a child of the first), the second the 395 parent of the third (and the third a child of the second), 396 etc. The following rules govern the creation of these 397 links: 399 If a message does not contain a Message-ID header line, 400 or the Message-ID header line does not contain a valid 401 Message ID, then assign a unique Message ID to this 402 message. 404 If two or more messages have the same Message ID, then 405 only use that Message ID in the first (lowest sequence 406 number) message, and assign a unique Message ID to each 407 of the subsequent messages with a duplicate of that 408 Message ID. 410 If no message can be found with a given Message ID, 411 create a dummy message with this ID. Use this dummy 412 message for all subsequent references to this ID. 414 If a message already has a parent, don't change the 415 existing link. This is done because the References 416 header line may have been truncated by a MUA. As a 417 result, there is no guarantee that the messages 418 corresponding to adjacent Message IDs in the References 419 header line are parent and child. 421 Do not create a parent/child link if creating that link 422 would introduce a loop. For example, before making 423 message A the parent of B, make sure that A is not a 424 descendent of B. 426 Note: Message ID comparisons are case-sensitive. 428 (B) Create a parent/child link between the last reference 429 (or NIL if there are no references) and the current message. 430 If the current message already has a parent, it is probably 431 the result of a truncated References header line, so break 432 the current parent/child link before creating the new 433 correct one. As in step 1.A, do not create the parent/child 434 link if creating that link would introduce a loop. Note 435 that if this message has no references, that it will now 436 have no parent. 438 Note: The parent/child links created in steps 1.A and 1.B 439 MUST be kept consistent with one another at ALL times. 441 (2) Gather together all of the messages that have no parents 442 and make them all children (siblings of one another) of a dummy 443 parent (the "root"). These messages constitute the first 444 (head) message of the threads created thus far. 446 (3) Prune dummy messages from the thread tree. Traverse each 447 thread under the root, and for each message: 449 If it is a dummy message with NO children, delete it. 451 If it is a dummy message with children, delete it, but 452 promote its children to the current level. In other words, 453 splice them in with the dummy's siblings. 455 Do not promote the children if doing so would make them 456 children of the root, unless there is only one child. 458 (4) Sort the messages under the root (top-level siblings only) 459 by sent date. In the case of an exact match on sent date or if 460 either of the Date: headers used in a comparison can not be 461 parsed, use the order in which the messages appear in the 462 mailbox (that is, by sequence number) to determine the order. 463 In the case of a dummy message, sort its children by sent date 464 and then use the first child for the top-level sort. 466 (5) Gather together messages under the root that have the same 467 base subject text. 469 (A) Create a table for associating base subjects with 470 messages, called the subject table. 472 (B) Populate the subject table with one message per each 473 base subject. For each child of the root: 475 (i) Find the subject of this thread, by using the base 476 subject from either the current message or its first 477 child if the current message is a dummy. This is the 478 thread subject. 480 (ii) If the thread subject is empty, skip this message. 482 (iii) Look up the message associated with the thread 483 subject in the subject table. 485 (iv) If there is no message in the subject table with the 486 thread subject, add the current message and the thread 487 subject to the subject table. 489 Otherwise, if the message in the subject table is not a 490 dummy, AND either of the following criteria are true: 492 The current message is a dummy, OR 494 The message in the subject table is a reply or forward 495 and the current message is not. 497 then replace the message in the subject table with the 498 current message. 500 (C) Merge threads with the same thread subject. For each 501 child of the root: 503 (i) Find the message's thread subject as in step 5.B.i 504 above. 506 (ii) If the thread subject is empty, skip this message. 508 (iii) Lookup the message associated with this thread 509 subject in the subject table. 511 (iv) If the message in the subject table is the current 512 message, skip this message. 514 Otherwise, merge the current message with the one in the 515 subject table using the following rules: 517 If both messages are dummies, append the current 518 message's children to the children of the message in 519 the subject table (the children of both messages 520 become siblings), and then delete the current message. 522 If the message in the subject table is a dummy and the 523 current message is not, make the current message a 524 child of the message in the subject table (a sibling 525 of its children). 527 If the current message is a reply or forward and the 528 message in the subject table is not, make the current 529 message a child of the message in the subject table (a 530 sibling of its children). 532 Otherwise, create a new dummy message and make both 533 the current message and the message in the subject 534 table children of the dummy. Then replace the message 535 in the subject table with the dummy message. 537 Note: Subject comparisons are case-insensitive, as 538 described under "Internationalization 539 Considerations." 541 (6) Traverse the messages under the root and sort each set of 542 siblings by sent date. Traverse the messages in such a way 543 that the "youngest" set of siblings are sorted first, and the 544 "oldest" set of siblings are sorted last (grandchildren are 545 sorted before children, etc). In the case of an exact match on 546 sent date or if either of the Date: headers used in a 547 comparison can not be parsed, use the order in which the 548 messages appear in the mailbox (that is, by sequence number) to 549 determine the order. In the case of a dummy message (which can 550 only occur with top-level siblings), use its first child for 551 sorting. 553 Example: C: A283 THREAD ORDEREDSUBJECT UTF-8 SINCE 5-MAR-2000 554 S: * THREAD (166)(167)(168)(169)(172)(170)(171) 555 (173)(174 (175)(176)(178)(181)(180))(179)(177 556 (183)(182)(188)(184)(185)(186)(187)(189))(190) 557 (191)(192)(193)(194 195)(196 (197)(198))(199) 558 (200 202)(201)(203)(204)(205)(206 207)(208) 559 S: A283 OK THREAD completed 560 C: A284 THREAD ORDEREDSUBJECT US-ASCII TEXT "gewp" 561 S: * THREAD 562 S: A284 OK THREAD completed 563 C: A285 THREAD REFERENCES UTF-8 SINCE 5-MAR-2000 564 S: * THREAD (166)(167)(168)(169)(172)((170)(179)) 565 (171)(173)((174)(175)(176)(178)(181)(180)) 566 ((177)(183)(182)(188 (184)(189))(185 186)(187)) 567 (190)(191)(192)(193)((194)(195 196))(197 198) 568 (199)(200 202)(201)(203)(204)(205 206 207)(208) 569 S: A285 OK THREAD completed 571 Note: The line breaks in the first and third client 572 responses are for editorial clarity and do not appear in 573 real THREAD responses. 575 4. Additional Responses 577 These responses are extensions to the [IMAP] base protocol. 579 The section headings of these responses are intended to correspond 580 with where they would be located in the main document. 582 BASE.7.2.SORT. SORT Response 584 Data: zero or more numbers 586 The SORT response occurs as a result of a SORT or UID SORT 587 command. The number(s) refer to those messages that match the 588 search criteria. For SORT, these are message sequence numbers; 589 for UID SORT, these are unique identifiers. Each number is 590 delimited by a space. 592 Example: S: * SORT 2 3 6 594 BASE.7.2.THREAD. THREAD Response 596 Data: zero or more threads 598 The THREAD response occurs as a result of a THREAD or UID THREAD 599 command. It contains zero or more threads. A thread consists of 600 a parenthesized list of thread members. 602 Thread members consist of zero or more message numbers, delimited 603 by spaces, indicating successive parent and child. This continues 604 until the thread splits into multiple sub-threads, at which point 605 the thread nests into multiple sub-threads with the first member 606 of each subthread being siblings at this level. There is no limit 607 to the nesting of threads. 609 The messages numbers refer to those messages that match the search 610 criteria. For THREAD, these are message sequence numbers; for UID 611 THREAD, these are unique identifiers. 613 Example: S: * THREAD (2)(3 6 (4 23)(44 7 96)) 615 The first thread consists only of message 2. The second thread 616 consists of the messages 3 (parent) and 6 (child), after which it 617 splits into two subthreads; the first of which contains messages 4 618 (child of 6, sibling of 44) and 23 (child of 4), and the second of 619 which contains messages 44 (child of 6, sibling of 4), 7 (child of 620 44), and 96 (child of 7). Since some later messages are parents 621 of earlier messages, the messages were probably moved from some 622 other mailbox at different times. 624 -- 2 626 -- 3 627 \-- 6 628 |-- 4 629 | \-- 23 630 | 631 \-- 44 632 \-- 7 633 \-- 96 635 Example: S: * THREAD ((3)(5)) 637 In this example, 3 and 5 are siblings of a parent which does not 638 match the search criteria (and/or does not exist in the mailbox); 639 however they are members of the same thread. 641 5. Formal Syntax of SORT and THREAD Commands and Responses 643 The following syntax specification uses the Augmented Backus-Naur 644 Form (ABNF) notation as specified in [ABNF]. It also uses [ABNF] 645 rules defined in [IMAP]. 647 sort = ["UID" SP] "SORT" SP sort-criteria SP search-criteria 649 sort-criteria = "(" sort-criterion *(SP sort-criterion) ")" 651 sort-criterion = ["REVERSE" SP] sort-key 653 sort-key = "ARRIVAL" / "CC" / "DATE" / "FROM" / "SIZE" / 654 "SUBJECT" / "TO" 656 thread = ["UID" SP] "THREAD" SP thread-alg SP search-criteria 658 thread-alg = "ORDEREDSUBJECT" / "REFERENCES" / thread-alg-ext 660 thread-alg-ext = atom 661 ; New algorithms MUST be registered with IANA 663 search-criteria = charset 1*(SP search-key) 665 charset = astring 666 ; CHARSET values MUST be registered with IANA 668 sort-data = "SORT" *(SP nz-number) 670 thread-data = "THREAD" [SP 1*thread-list] 672 thread-list = "(" (thread-members / thread-nested) ")" 674 thread-members = nz-number *(SP nz-number) [SP thread-nested] 676 thread-nested = 2*thread-list 678 The following syntax describes base subject extraction rules (2)-(6): 680 subject = *subj-leader [subj-middle] *subj-trailer 682 subj-refwd = ("re" / ("fw" ["d"])) *WSP [subj-blob] ":" 684 subj-blob = "[" *BLOBCHAR "]" *WSP 686 subj-fwd = subj-fwd-hdr subject subj-fwd-trl 688 subj-fwd-hdr = "[fwd:" 690 subj-fwd-trl = "]" 692 subj-leader = (*subj-blob subj-refwd) / WSP 694 subj-middle = *subj-blob (subj-base / subj-fwd) 695 ; last subj-blob is subj-base if subj-base would 696 ; otherwise be empty 698 subj-trailer = "(fwd)" / WSP 700 subj-base = NONWSP *(*WSP NONWSP) 701 ; can be a subj-blob 703 BLOBCHAR = %x01-5a / %x5c / %x5e-7f 704 ; any CHAR except '[' and ']' 706 NONWSP = %x01-08 / %x0a-1f / %x21-7f 707 ; any CHAR other than WSP 709 6. Security Considerations 711 The SORT and THREAD extensions do not raise any security 712 considerations that are not present in the base [IMAP] protocol, and 713 these issues are discussed in [IMAP]. Nevertheless, it is important 714 to remember that [IMAP] protocol transactions, including message 715 data, are sent in the clear over the network unless protection from 716 snooping is negotiated, either by the use of STARTTLS, privacy 717 protection is negotiated in the AUTHENTICATE command, or some other 718 protection mechanism is in effect. 720 7. Internationalization Considerations 722 Strings in charsets other than US-ASCII and UTF-8 must be converted 723 to UTF-8 prior to any comparisons. String comparisons used in SORT 724 and THREAD collations are performed as described in [IMAP-I18N]. 726 Translations of the "re" or "fw"/"fwd" tokens are not specified for 727 removal in the base subject extraction process. An attempt to add such 728 translated tokens would result in a geometrically complex, and 729 ultimately unimplementable, task. 731 Instead, note that [RFC-2822] section 3.6.5 recommends that "re:" (from 732 the Latin "res", in the matter of) be used to identify a reply. 733 Although it is evident that, from the multiple forms of token to 734 identify a forwarded message, there is considerable variation found in 735 the wild, the variations are (still) manageable. Consequently, it is 736 suggested that "re:" and one of the variations of the tokens for forward 737 supported by the base subject extraction rules be adopted for Internet 738 mail messages, since doing so makes it a simple display time task to 739 localize the token language for the user. 741 8. IANA Considerations 743 [IMAP] capabilities are registered by publishing a standards track or 744 IESG approved experimental RFC. This document constitutes registration 745 of the SORT and THREAD capabilities in the [IMAP] capabilities registry. 747 This document creates a new [IMAP] threading algorithms registry, which 748 registers threading algorithms by publishing a standards track or IESG 749 approved experimental RFC. This document constitutes registration of 750 the ORDEREDSUBJECT and REFERENCES algorithms in that registry. 752 Appendices 754 A. Normative References 756 The following documents are normative to this document: 758 [ABNF] Crocker, D., and Overell, P. "Augmented BNF 759 for Syntax Specifications: ABNF", RFC 2234, 760 November 1997. 762 [CHARSET] Freed, N. and J. Postel, "IANA Character Set 763 Registration Procedures", RFC 2978, October 764 2000. 766 [IMAP] Crispin, M., "Internet Message Access Protocol - 767 Version 4rev1", RFC 3501, March 2003. 769 [IMAP-I18N] Newman, C. "Internet Message Access Protocol 770 Internationalization", Work in Progress. 772 [KEYWORDS] Bradner, S. "Key words for use in RFCs to 773 Indicate Requirement Levels", RFC 2119, Harvard 774 University, March 1997. 776 [RFC-2822] Resnick, P. "Internet Message Format", RFC 2822, 777 April 2001. 779 B. Informative References 781 The following documents are informative to this document: 783 [IMAP-MODELS] Crispin, M., "Distributed Electronic Mail Models 784 in IMAP4", RFC 1733, December 1994. 786 [THREADING] Zawinski, J. "Message Threading", 787 http://www.jwz.org/doc/threading.html, 1997-2002. 789 Author's Address 791 Mark R. Crispin 792 Networks and Distributed Computing 793 University of Washington 794 4545 15th Avenue NE 795 Seattle, WA 98105-4527 797 Phone: (206) 543-5762 799 EMail: MRC@CAC.Washington.EDU 801 Kenneth Murchison 802 Oceana Matrix Ltd. 803 21 Princeton Place 804 Orchard Park, NY 14127 806 Phone: (716) 662-8973 x26 808 EMail: ken@oceana.com 810 IPR Disclosure Acknowledgement 812 By submitting this Internet-Draft, I certify that any applicable 813 patent or other IPR claims of which I am aware have been disclosed, 814 and any of which I become aware will be disclosed, in accordance with 815 RFC 3668. 817 Intellectual Property Statement 819 The IETF takes no position regarding the validity or scope of any 820 intellectual property or other rights that might be claimed to 821 pertain to the implementation or use of the technology described in 822 this document or the extent to which any license under such rights 823 might or might not be available; neither does it represent that it 824 has made any effort to identify any such rights. Information on the 825 IETF's procedures with respect to rights in standards-track and 826 standards-related documentation can be found in BCP-11. Copies of 827 claims of rights made available for publication and any assurances of 828 licenses to be made available, or the result of an attempt made to 829 obtain a general license or permission for the use of such 830 proprietary rights by implementors or users of this specification can 831 be obtained from the IETF Secretariat. 833 The IETF invites any interested party to bring to its attention any 834 copyrights, patents or patent applications, or other proprietary 835 rights which may cover technology that may be required to practice 836 this standard. Please address the information to the IETF Executive 837 Director. 839 Full Copyright Statement 841 Copyright (C) The Internet Society (2004). This document is subject 842 to the rights, licenses and restrictions contained in BCP 78 and 843 except as set forth therein, the authors retain all their rights. 845 This document and the information contained herein are provided on an 846 "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE 847 REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE 848 INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR 849 IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF 850 THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED 851 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 853 Intellectual Property 855 The IETF takes no position regarding the validity or scope of any 856 Intellectual Property Rights or other rights that might be claimed 857 to pertain to the implementation or use of the technology 858 described in this document or the extent to which any license 859 under such rights might or might not be available; nor does it 860 represent that it has made any independent effort to identify any 861 such rights. Information on the procedures with respect to 862 rights in RFC documents can be found in BCP 78 and BCP 79. 864 Copies of IPR disclosures made to the IETF Secretariat and any 865 assurances of licenses to be made available, or the result of an 866 attempt made to obtain a general license or permission for the use 867 of such proprietary rights by implementers or users of this 868 specification can be obtained from the IETF on-line IPR repository 869 at http://www.ietf.org/ipr. 871 The IETF invites any interested party to bring to its attention 872 any copyrights, patents or patent applications, or other 873 proprietary rights that may cover technology that may be required 874 to implement this standard. Please address the information to the 875 IETF at ietf-ipr@ietf.org. 877 Acknowledgement 879 Funding for the RFC Editor function is currently provided by the 880 Internet Society.