/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
/* Implemented against draft-ietf-imapext-sort-10 and
draft-ietf-imapext-thread-12 */
#include "lib.h"
#include "buffer.h"
#include "charset-utf8.h"
#include "message-header-decode.h"
#include "imap-base-subject.h"
{
bool last_lwsp;
/* check if we need to do anything */
while (*data != '\0') {
break;
data++;
}
if (*data == '\0')
return;
while (*data != '\0') {
if (!last_lwsp) {
*dest++ = ' ';
}
} else {
}
data++;
}
*dest = '\0';
}
bool *is_reply_or_forward_r)
{
const char *data;
/* subj-trailer = "(fwd)" / WSP */
return;
size--;
else if (size >= 5 &&
size -= 5;
} else {
break;
}
}
}
}
{
if (*data != '[')
return FALSE;
data++;
data++;
if (*data != ']')
return FALSE;
data++;
if (*data == ' ')
data++;
return TRUE;
}
bool *is_reply_or_forward_r)
{
/* subj-leader = (*subj-blob subj-refwd) / WSP
subj-blob = "[" *BLOBCHAR "]" *WSP
subj-refwd = ("re" / ("fw" ["d"])) *WSP [subj-blob] ":"
BLOBCHAR = %x01-5a / %x5c / %x5e-7f
; any CHAR except '[' and ']' */
if (*data == ' ') {
/* independent from checks below - always removed */
*start_pos += 1;
}
while (*data == '[') {
if (!remove_blob(&data))
return ret;
}
data += 2;
data += 3;
data += 2;
else
return ret;
if (*data == ' ')
data++;
return ret;
if (*data != ':')
return ret;
data++;
return TRUE;
}
{
return TRUE;
}
return FALSE;
}
bool *is_reply_or_forward_r)
{
/* subj-fwd = subj-fwd-hdr subject subj-fwd-trl
subj-fwd-hdr = "[fwd:"
subj-fwd-trl = "]" */
return FALSE;
return FALSE;
*start_pos += 5;
return TRUE;
}
bool *is_reply_or_forward_r)
{
bool found;
/* (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. */
start_pos = 0;
do {
/* (2) Remove all trailing text of the subject that matches
the subj-trailer ABNF, repeat until no more matches are
possible. */
do {
/* (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. */
} while (found);
/* (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. */
}