commit 83d97648a2f3a717c8051c8b6e8707c01a135631
parent beaef0773ca348cf3d8a5dca947190ac5aa3c601
Author: Christoph Lohmann <20h@r-36.net>
Date: Sun, 23 Jul 2017 18:16:55 +0200
The first parameter has no MIME ordering.
Diffstat:
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/mime.c b/mime.c
@@ -523,10 +523,18 @@ mime_sanitizeparams(llist_t *params)
llistelem_t *param, *hit, *nparam;
llist_t *reorder, *hits;
char *key, *nvalue;
- int klen, i;
+ int klen, i, n;
reorder = llist_new();
+ //printf("mime_sanitizeparams: start\n");
+ n = 0;
forllist(params, param) {
+ if (n == 0) {
+ llist_add(reorder, param->key, NULL, 0);
+ n++;
+ continue;
+ }
+
key = param->key;
klen = strlen(key);
@@ -602,6 +610,7 @@ mime_parseheader(char *field)
tok = buf;
ret = llist_new();
+ //printf("mime_parseheader: buf = '%s'\n", buf);
while (tok[0] != '\0') {
key = NULL;
value = NULL;
@@ -616,11 +625,13 @@ mime_parseheader(char *field)
tok[tlen-1] = '\0';
tlen--;
}
+ //printf("mime_parseheader: after sanitize: tok = '%s'\n", tok);
/*
* 1.) ([\t\r\v\f ]*)key
*/
key = tok + strspn(tok, "\t\r\v\f ");
+ //printf("mime_parseheader: key = '%s'\n", tok);
/*
* 2.) key
@@ -629,13 +640,16 @@ mime_parseheader(char *field)
if (tok[0] == ';' || tok[0] == '\0') {
quot = tok[0];
tok[0] = '\0';
- if (strlen(key) > 0)
+ if (strlen(key) > 0) {
+ //printf("mime_parseheader: add key '%s'\n", key);
llist_add(ret, key, NULL, 0);
+ }
if (quot != '\0')
tok++;
continue;
}
+ //printf("mime_parseheader: tok = '%s'\n", tok);
if (tok[0] == '=') {
eq = tok;
} else {
@@ -704,11 +718,12 @@ mime_parseheader(char *field)
break;
}
+ //printf("mime_parseheader: add %s = '%s'\n", key, value);
llist_add(ret, key, value, strlen(value)+1);
}
free(buf);
- if (ret->len > 0)
+ if (ret->len > 1)
return mime_sanitizeparams(ret);
llist_free(ret);
@@ -868,6 +883,7 @@ mime_parsebufintern(mime_t *mime, char *str, int len)
rp = str;
p = str;
for (; (rp = sgets(buf, sizeof(buf)-1, &p));) {
+ //printf("line '%s'\n", buf);
blen = strlen(buf);
if (buf[blen-1] == '\r')
buf[blen-1] = '\0';
@@ -960,6 +976,7 @@ mimeparsebufagain:
break;
}
}
+ //printf("return mime_preparepart\n");
return mime_preparepart(mime);
mimeparsebufbodyparse:
@@ -980,6 +997,8 @@ mimeparsebufbodyparse:
//printf("mime->body = \"%s\"\n", mime->body);
return mime;
+ } else {
+ //printf("There is a boundary.\n");
}
partlen = 0;
diff --git a/view.c b/view.c
@@ -425,6 +425,7 @@ viewmain(int argc, char *argv[])
ide = llist_get((llist_t *)msg->data, "id");
if (ide == NULL)
continue;
+
mime = mime_parsebuf((char *)elem->data, elem->datalen);
if (mime == NULL)
continue;