/* Copyright (c) 2008-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "rfc822-parser.h"
#include "rfc2231-parser.h"
struct rfc2231_parameter {
unsigned int idx;
bool extended;
};
const struct rfc2231_parameter *r2)
{
int ret;
if (ret != 0)
return ret;
}
{
if (*src == '%')
else
}
}
const char *const **result_r)
{
int ret;
/* Get a list of all parameters. RFC 2231 uses key*<n>[*]=value pairs,
which we want to merge to a key[*]=value pair. Save them to a
separate array. */
if (ret < 0) {
/* try to continue anyway.. */
break;
continue;
}
if (p != NULL) {
p2 = p;
if (p[1] != '\0') {
p++;
rfc2231_param.idx = 0;
for (; *p >= '0' && *p <= '9'; p++) {
}
}
if (*p != '*')
else {
p++;
}
if (*p != '\0')
p = NULL;
else {
&rfc2231_param, 1);
}
}
if (p == NULL) {
}
}
if (array_count(&rfc2231_params_arr) == 0) {
/* No RFC 2231 parameters */
return broken ? -1 : 0;
}
/* Merge the RFC 2231 parameters. Since their order isn't guaranteed to
be ascending, start by sorting them. */
/* keys are now sorted primarily by their name and secondarily by
their index. If any indexes are missing, fallback to assuming
these aren't RFC 2231 encoded parameters. */
next_idx = 0;
for (j = i; j < count; j++) {
rfc2231_params[j].key) != 0)
break;
/* missing indexes */
}
if (rfc2231_params[j].extended)
next_idx++;
}
next = j;
if (!ok) {
/* missing indexes */
for (j = i; j < next; j++) {
rfc2231_params[j].extended ?
"%s*%u*" : "%s*%u",
rfc2231_params[j].key,
rfc2231_params[j].idx);
}
} else {
/* everything was successful */
str_truncate(str, 0);
for (j = i; j < next; j++) {
if (!rfc2231_params[j].extended &&
rfc2231_params[j].value);
} else {
rfc2231_params[j].value);
}
}
if (have_extended)
}
}
return broken ? -1 : 0;
}