diff options
author | Kevin McCarthy <kevin@8t8.us> | 2018-11-05 16:19:03 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2018-11-05 16:19:03 -0800 |
commit | 1681a2abb19b760097ac542c0885cbc1bc460199 (patch) | |
tree | f78d26b4bf9b8d25a832f2950a4f00b071507368 /init.c | |
parent | e60594844c469e199757b6dd2688a3047b440b2c (diff) |
Prevent $charset from having multiple values.
Mutt relies on it being a single character set, but failed to make
sure of that in check_charset().
Thanks to Hans-Peter Jansen for reporting the problem, and to Mel
Gorman for working with me to track down the issue in his
configuration.
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -1892,6 +1892,18 @@ static int check_charset (struct option_t *opt, const char *val) char *p, *q = NULL, *s = safe_strdup (val); int rc = 0, strict = strcmp (opt->option, "send_charset") == 0; + /* $charset should be nonempty, and a single value - not a colon + * delimited list */ + if (mutt_strcmp (opt->option, "charset") == 0) + { + if (!s || (strchr (s, ':') != NULL)) + { + FREE (&s); + return -1; + } + } + + /* other values can be empty */ if (!s) return rc; @@ -2277,10 +2289,8 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err) } else if (DTYPE (MuttVars[idx].type) == DT_STR) { - if ((strstr (MuttVars[idx].option, "charset") && - check_charset (&MuttVars[idx], tmp->data) < 0) | - /* $charset can't be empty, others can */ - (strcmp(MuttVars[idx].option, "charset") == 0 && ! *tmp->data)) + if (strstr (MuttVars[idx].option, "charset") && + check_charset (&MuttVars[idx], tmp->data) < 0) { snprintf (err->data, err->dsize, _("Invalid value for option %s: \"%s\""), MuttVars[idx].option, tmp->data); |