rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | README | LICENSE

commit e54cce90d3001cf915f9108e7914c9beba0c316e
parent 31684f2c1007425850a961b29357cebce23902f2
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon,  1 Apr 2024 15:46:10 +0200

Fix mime_sanitizeparams for multi-order keys.

Diffstat:
Mmime.c | 28++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/mime.c b/mime.c @@ -528,7 +528,7 @@ mime_sanitizeparams(llist_t *params) { llistelem_t *param, *hit, *nparam; llist_t *reorder, *hits; - char *key, *nvalue; + char *key, *nvalue, *dvalue; int klen, i, n; reorder = llist_new(); @@ -542,20 +542,8 @@ mime_sanitizeparams(llist_t *params) } key = param->key; - klen = strlen(key); - //printf("key = %s\n", key); - if (key[klen-2] == '*') { - nvalue = mime_decodeparam((char *)param->data); - if (nvalue != NULL) { - //printf("decoded: %s\n", nvalue); - free(param->data); - param->data = nvalue; - param->datalen = strlen(nvalue)+1; - } - key[klen-2] = '\0'; - //printf("key after = %s\n", key); - } + klen = strlen(key); nvalue = strrchr(param->key, '*'); if (nvalue == NULL) @@ -565,8 +553,18 @@ mime_sanitizeparams(llist_t *params) break; if (nvalue[i]) continue; + //printf("nvalue = %s\n", nvalue); + + dvalue = mime_decodeparam((char *)param->data); + if (dvalue != NULL) { + //printf("decoded: %s\n", dvalue); + free(param->data); + param->data = dvalue; + param->datalen = strlen(dvalue)+1; + } nvalue[0] = '\0'; + //printf("key after = %s\n", key); if (llist_get(reorder, param->key) != NULL) llist_add(reorder, param->key, NULL, 0); nvalue[0] = '*'; @@ -580,6 +578,7 @@ mime_sanitizeparams(llist_t *params) forllist(params, nparam) { if (!strncmp(nparam->key, param->key, strlen(param->key))) { + //printf("nparam->key = %s\n", nparam->key); llist_add(hits, nparam->key, nparam->data, nparam->datalen); } @@ -591,6 +590,7 @@ mime_sanitizeparams(llist_t *params) nparam = llistelem_new(param->key, NULL, 0); hits = llist_internsort(hits, mime_paramsort); + forllist(hits, hit) { nparam->data = memdupcat(nparam->data, nparam->datalen, hit->data,