sField < pFieldEnd;
pField++, sField++)
{
- if (*pField=='\"') quote = 1 - quote;
- if (!quote) {
- if (isspace(*sField))
- {
- *pField = ' ';
- pField++;
- sField++;
-
- while ((sField < pFieldEnd) &&
- isspace(*sField))
+ if ((*sField=='\r') || (*sField=='\n')) {
+ sField++;
+ if (*sField == '\n')
+ sField++;
+ *pField = *sField;
+ }
+ else {
+ if (*sField=='\"') quote = 1 - quote;
+ if (!quote) {
+ if (isspace(*sField))
+ {
+ *pField = ' ';
+ pField++;
sField++;
+
+ while ((sField < pFieldEnd) &&
+ isspace(*sField))
+ sField++;
+ *pField = *sField;
+ }
+ else *pField = *sField;
}
+ else *pField = *sField;
}
- else *pField = *sField;
}
*pField = '\0';
*FieldEnd = pField - 1;
valueend = key + len;
* ( key + (colonpos - beg) ) = '\0';
value = &key[(colonpos - beg) + 1];
+/* printf("Header: [%s]\nValue: [%s]\n", key, value); */
unfold_rfc822_field(&value, &valueend);
- valuelen = valueend - value;
+ valuelen = valueend - value + 1;
+/* printf("UnfoldedValue: [%s]\n", value); */
/*
* Here's the big rfc822-to-citadel loop.
processed = 1;
}
+ else if (!strcasecmp(key, "Reply-To")) {
+ if (msg->cm_fields['K'] != NULL) {
+ free(msg->cm_fields['K']);
+ }
+ msg->cm_fields['K'] = strndup(value, valuelen);
+ processed = 1;
+ }
+
else if (!strcasecmp(key, "In-reply-to")) {
if (msg->cm_fields['W'] == NULL) { /* References: supersedes In-reply-to: */
msg->cm_fields['W'] = strndup(value, valuelen);
(done == 0) )
{
- if ((*pos=='\n') &&
- (!isspace(*(pos+1))))
+ if ( (*pos=='\n') && ((*(pos+1))!=0x20) && ((*(pos+1))!=0x09) )
{
end = pos;
}
/* Strip the field out of the RFC822 header if we used it */
if (!converted) {
StrBufAppendBufPlain(OtherHeaders, beg, end - beg, 0);
+ StrBufAppendBufPlain(OtherHeaders, HKEY("\n"), 0);
}
/* If we've hit the end of the message, bail out */
if (pos >= totalend)
alldone = 1;
}
+ StrBufAppendBufPlain(OtherHeaders, HKEY("\n"), 0);
if (pos < totalend)
StrBufAppendBufPlain(OtherHeaders, pos, totalend - pos, 0);
FreeStrBuf(rfc822);
* The caller is responsible for freeing the returned buffer. If the requested
* field is not present, or anything else goes wrong, it returns NULL.
*/
-char *rfc822_fetch_field(char *rfc822, char *fieldname) {
+char *rfc822_fetch_field(const char *rfc822, const char *fieldname) {
char *fieldbuf = NULL;
- char *end_of_headers;
- char *field_start;
- char *ptr;
+ const char *end_of_headers;
+ const char *field_start;
+ const char *ptr;
char *cont;
char fieldhdr[SIZ];
snprintf(fieldhdr, sizeof fieldhdr, "%s:", fieldname);
/* Locate the end of the headers, so we don't run past that point */
- end_of_headers = bmstrcasestr(rfc822, "\n\r\n");
+ end_of_headers = cbmstrcasestr(rfc822, "\n\r\n");
if (end_of_headers == NULL) {
- end_of_headers = bmstrcasestr(rfc822, "\n\n");
+ end_of_headers = cbmstrcasestr(rfc822, "\n\n");
}
if (end_of_headers == NULL) return (NULL);
- field_start = bmstrcasestr(rfc822, fieldhdr);
+ field_start = cbmstrcasestr(rfc822, fieldhdr);
if (field_start == NULL) return(NULL);
if (field_start > end_of_headers) return(NULL);
strcpy(fieldbuf, "");
ptr = field_start;
- ptr = memreadline(ptr, fieldbuf, SIZ-strlen(fieldbuf) );
+ ptr = cmemreadline(ptr, fieldbuf, SIZ-strlen(fieldbuf) );
while ( (isspace(ptr[0])) && (ptr < end_of_headers) ) {
strcat(fieldbuf, " ");
cont = &fieldbuf[strlen(fieldbuf)];
- ptr = memreadline(ptr, cont, SIZ-strlen(fieldbuf) );
+ ptr = cmemreadline(ptr, cont, SIZ-strlen(fieldbuf) );
striplt(cont);
}