File: draft-ietf-imapext-sort-06.txt

package info (click to toggle)
libmail-imapclient-perl 2.1.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,236 kB
  • ctags: 231
  • sloc: perl: 11,273; makefile: 56
file content (564 lines) | stat: -rw-r--r-- 14,962 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564






IMAP Extensions Working Group                                 M. Crispin
INTERNET-DRAFT: IMAP SORT                                   K. Murchison
Document: internet-drafts/draft-ietf-imapext-sort-06.txt   December 2000


           INTERNET MESSAGE ACCESS PROTOCOL - SORT EXTENSION

Status of this Memo

   This document is an Internet-Draft and is in full conformance with
   all provisions of Section 10 of RFC 2026.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF), its areas, and its working groups.  Note that
   other groups may also distribute working documents as
   Internet-Drafts.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   The list of current Internet-Drafts can be accessed at
   http://www.ietf.org/ietf/1id-abstracts.txt

   To view the list Internet-Draft Shadow Directories, see
   http://www.ietf.org/shadow.html.

   A revised version of this document will be submitted to the RFC
   editor as an Informational Document for the Internet Community.

   A revised version of this draft document, describing an expanded
   version of this protocol extension, will be submitted to the RFC
   editor as a Proposed Standard for the Internet Community.

   Discussion and suggestions for improvement are requested, and should
   be sent to ietf-imapext@IMC.ORG.  This document will expire before 29
   June 2001.  Distribution of this memo is unlimited.


Abstract

   This document describes an experimental server-based sorting
   extension to the IMAP4rev1 protocol, as implemented by the University
   of Washington's IMAP toolkit.  This extension provides substantial
   performance improvements for IMAP clients which offer sorted views.

   A server which supports this extension indicates this with a



Crispin                                                         [Page 1]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


   capability name of "SORT".  Client implementations SHOULD accept any
   capability name which begins with "SORT" as indicating support for
   the extension described in this document.  This provides for future
   upwards-compatible extensions.

   At the time of this document was written, the IMAP Extensions Working
   Group (IETF-IMAPEXT) was considering upwards-compatible additions to
   the SORT extension described in this document, tentatively called the
   SORT2 extension.










































Crispin                                                         [Page 2]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


Extracted Subject Text

   The "SUBJECT" SORT criteria uses a version of the subject which has
   specific subject artifacts of deployed Internet mail software
   removed.  Due to the complexity of these artifacts, the formal syntax
   for the subject extraction rules is ambiguous.  The following
   procedure is followed to determine the actual "base subject" which is
   used to sort by subject:

        (1) Convert any RFC 2047 encoded-words in the subject to
        UTF-8.  Convert all tabs and continuations to space.
        Convert all multiple spaces to a single space.

        (2) Remove all trailing text of the subject that matches
        the subj-trailer ABNF, repeat until no more matches are
        possible.

        (3) Remove all prefix text of the subject that matches the
        subj-leader ABNF.

        (4) If there is prefix text of the subject that matches the
        subj-blob ABNF, and removing that prefix leaves a non-empty
        subj-base, then remove the prefix text.

        (5) Repeat (3) and (4) until no matches remain.

   Note: it is possible to defer step (2) until step (6), but this
   requires checking for subj-trailer in step (4).

        (6) If the resulting text begins with the subj-fwd-hdr ABNF
        and ends with the subj-fwd-trl ABNF, remove the
        subj-fwd-hdr and subj-fwd-trl and repeat from step (2).

        (7) The resulting text is the "base subject" used in the
        SORT.

   All servers and disconnected clients MUST use exactly this algorithm
   when sorting by subject.  Otherwise there is potential for a user to
   get inconsistent results based on whether they are running in
   connected or disconnected IMAP mode.











Crispin                                                         [Page 3]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


Additional Commands

   This command is an extension to the IMAP4rev1 base protocol.

   The section header is intended to correspond with where it would be
   located in the main document if it was part of the base
   specification.


6.3.SORT.       SORT Command

   Arguments:  sort program
               charset specification
               searching criteria (one or more)

   Data:       untagged responses: SORT

   Result:     OK - sort completed
               NO - sort error: can't sort that charset or
                    criteria
               BAD - command unknown or arguments invalid

      The SORT command is a variant of SEARCH with sorting semantics for
      the results.  Sort has two arguments before the searching criteria
      argument; a parenthesized list of sort criteria, and the searching
      charset.

      Note that unlike SEARCH, the searching charset argument is
      mandatory.  The US-ASCII and UTF-8 charsets MUST be implemented.
      All other charsets are optional.

      There is also a UID SORT command which corresponds to SORT the way
      that UID SEARCH corresponds to SEARCH.

      The SORT command first searches the mailbox for messages that
      match the given searching criteria using the charset argument for
      the interpretation of strings in the searching criteria.  It then
      returns the matching messages in an untagged SORT response, sorted
      according to one or more sort criteria.

      If two or more messages exactly match according to the sorting
      criteria, these messages are sorted according to the order in
      which they appear in the mailbox.  In other words, there is an
      implicit sort criterion of "sequence number".

      When multiple sort criteria are specified, the result is sorted in
      the priority order that the criteria appear.  For example,
      (SUBJECT DATE) will sort messages in order by their subject text;



Crispin                                                         [Page 4]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


      and for messages with the same subject text will sort by their
      sent date.

      Untagged EXPUNGE responses are not permitted while the server is
      responding to a SORT command, but are permitted during a UID SORT
      command.

      The defined sort criteria are as follows.  Refer to the Formal
      Syntax section for the precise syntactic definitions of the
      arguments.  If the associated RFC-822 header for a particular
      criterion is absent, it is treated as the empty string.  The empty
      string always collates before non-empty strings.

      ARRIVAL
         Internal date and time of the message.  This differs from the
         ON criteria in SEARCH, which uses just the internal date.

      CC
         RFC-822 local-part of the first "cc" address.

      DATE
         Sent date and time from the Date: header, adjusted by time
         zone.  This differs from the SENTON criteria in SEARCH, which
         uses just the date and not the time, nor adjusts by time zone.

      FROM
         RFC-822 local-part of the "From" address.

      REVERSE
         Followed by another sort criterion, has the effect of that
         criterion but in reverse order.
            Note: REVERSE only reverses a single criterion, and does not
            affect the implicit "sequence number" sort criterion if all
            other criteria are identicial.  Consequently, a sort of
            REVERSE SUBJECT is not the same as a reverse ordering of a
            SUBJECT sort.
            This can be avoided by use of additional criteria, e.g.
            SUBJECT DATE vs. REVERSE SUBJECT REVERSE DATE.  In general,
            however, it's better (and faster, if the client has a
            "reverse current ordering" command) to reverse the results
            in the client instead of issuing a new SORT.

      SIZE
         Size of the message in octets.

      SUBJECT
         Extracted subject text.




Crispin                                                         [Page 5]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


      TO
         RFC-822 local-part of the first "To" address.


   Example:    C: A282 SORT (SUBJECT) UTF-8 SINCE 1-Feb-1994
               S: * SORT 2 84 882
               S: A282 OK SORT completed
               C: A283 SORT (SUBJECT REVERSE DATE) UTF-8 ALL
               S: * SORT 5 3 4 1 2
               S: A283 OK SORT completed
               C: A284 SORT (SUBJECT) US-ASCII TEXT "not in mailbox"
               S: * SORT
               S: A284 OK SORT completed






































Crispin                                                         [Page 6]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


Additional Responses

   This response is an extension to the IMAP4rev1 base protocol.

   The section heading of this response is intended to correspond with
   where it would be located in the main document.


7.2.SORT.       SORT Response

   Data:       zero or more numbers

      The SORT response occurs as a result of a SORT or UID SORT
      command.  The number(s) refer to those messages that match the
      search criteria.  For SORT, these are message sequence numbers;
      for UID SORT, these are unique identifiers.  Each number is
      delimited by a space.

   Example:    S: * SORT 2 3 6
































Crispin                                                         [Page 7]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


Formal Syntax of SORT commands and Responses

   sort-data       = "SORT" *(SP nz-number)

   sort            = ["UID" SP] "SORT" SP
                     "(" sort-criterion *(SP sort-criterion) ")"
                     SP search_charset 1*(SP search_key)

   sort-criterion  = ["REVERSE" SP] sort-key

   sort-key        = "ARRIVAL" / "CC" / "DATE" / "FROM" / "SIZE" /
                     "SUBJECT" / "TO"


   The following syntax describes subject extraction rules (2)-(6):

   subject         = *subj-leader [subj-middle] *subj-trailer

   subj-refwd      = ("re" / ("fw" ["d"])) *WSP [subj-blob] ":"

   subj-blob       = "[" *BLOBCHAR "]" *WSP

   subj-fwd        = subj-fwd-hdr subject subj-fwd-trl

   subj-fwd-hdr    = "[fwd:"

   subj-fwd-trl    = "]"

   subj-leader     = (*subj-blob subj-refwd) / WSP

   subj-middle     = *subj-blob (subj-base / subj-fwd)
                   ; last subj-blob is subj-base if subj-base would
                   ; otherwise be empty

   subj-trailer    = "(fwd)" / WSP

   subj-base       = NONWSP *([*WSP] NONWSP)
                   ; can be a subj-blob

   BLOBCHAR        = %x01-5a / %x5c / %x5e-7f
                   ; any CHAR except '[' and ']'

   NONWSP          = %x01-08 / %x0a-1f / %x21-7f
                   ; any CHAR other than WSP







Crispin                                                         [Page 8]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


Security Considerations

   Security issues are not discussed in this memo.


Internationalization Considerations

   By default, strings are sorted according to the "minimum sorting
   collation algorithm".  All implementations of SORT MUST implement the
   minimum sorting collation algorithm.

   In the minimum sorting collation algorithm, the Basic Latin
   alphabetics (U+0041 to U+005A uppercase, U+0061 to U+007A lowercase)
   are sorted in a case-insensitive fashion; that is, "A" (U+0041) and
   "a" (U+0061) are treated as exact equals.  The characters U+005B to
   U+0060 are sorted after the Basic Latin alphabetics; for example,
   U+005E is sorted after U+005A and U+007A.  All other characters are
   sorted according to their octet values, as expressed in UTF-8.  No
   attempt is made to treat composed characters specially, or to do
   case-insensitive comparisons of composed characters.

        Note: this means, among other things, that the composed
        characters in the Latin-1 Supplement are not compared in
        what would be considered an ISO 8859-1 "case-insensitive"
        fashion.  Case comparison rules for characters with
        diacriticals differ between languages; the minimum sorting
        collation does not attempt to deal with this at all.  This
        is reserved for other sorting collations, which may be
        language-specific.

   Other sorting collations, and the ability to change the sorting
   collation, will be defined in a separate document dealing with IMAP
   internationalization.

   It is anticipated that there will be a generic Unicode sorting
   collation, which will provide generic case-insensitivity for
   alphabetic scripts, specification of composed character handling, and
   language-specific sorting collations.  A server which implements
   non-default sorting collations will modify its sorting behavior
   according to the selected sorting collation.

   Non-English translations of "Re" or "Fw"/"Fwd" are not specified for
   removal in the extracted subject text process.  By specifying that
   only the English forms of the prefixes are used, it becomes a simple
   display time task to localize the prefix language for the user.  If,
   on the other hand, prefixes in multiple languages are permitted, the
   result is a geometrically complex, and ultimately unimplementable,
   task.  In order to improve the ability to support non-English display



Crispin                                                         [Page 9]

INTERNET DRAFT                 IMAP SORT            EXPIRES 29 June 2000


   in Internet mail clients, only the English form of these prefixes
   should be transmitted in Internet mail messages.


Author's Address

   Mark R. Crispin
   Networks and Distributed Computing
   University of Washington
   4545 15th Avenue NE
   Seattle, WA  98105-4527

   Phone: (206) 543-5762

   EMail: MRC@CAC.Washington.EDU


   Kenneth Murchison
   Oceana Matrix Ltd.
   21 Princeton Place
   Orchard Park, NY 14127

   Phone: (716) 662-8973 x26

   EMail: ken@oceana.com


























Crispin                                                        [Page 10]