diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-03-13 00:39:16 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2005-03-13 00:39:16 +0000 |
commit | 514472a071f8f49b48eaa460ce34452b87db2ca2 (patch) | |
tree | 17b58cc189b2d922c1e894c29f05122488af9c79 | |
parent | b81c839194e7f24524f7d9a27dadc10cb5d03d80 (diff) | |
download | mailutils-514472a071f8f49b48eaa460ce34452b87db2ca2.tar.gz mailutils-514472a071f8f49b48eaa460ce34452b87db2ca2.tar.bz2 |
(mime_context_fill): Remove leading whitespace
when preparing lists.
(mime_context_get_content_type_value): Return integer code.
(expand_string): Fixed expansion of %{name}
-rw-r--r-- | lib/mailcap.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/mailcap.c b/lib/mailcap.c index 8e0d65f97..d32df7f49 100644 --- a/lib/mailcap.c +++ b/lib/mailcap.c @@ -78,7 +78,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, list_create (&ctx->values); while ((p = strtok_r (NULL, ";", &sp))) - list_append (ctx->values, p); + { + while (*p && isspace (*p)) + p++; + list_append (ctx->values, p); + } if (no_ask) { @@ -86,7 +90,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, list_create (&ctx->no_ask_types); for (p = strtok_r (ctx->no_ask_str, ",", &sp); p; p = strtok_r (NULL, ",", &sp)) - list_append (ctx->no_ask_types, p); + { + while (*p && isspace (*p)) + p++; + list_append (ctx->no_ask_types, p); + } } } @@ -147,13 +155,14 @@ mime_context_get_input (struct mime_context *ctx, stream_t *pinput) *pinput = ctx->input; } -static void +static int mime_context_get_content_type_value (struct mime_context *ctx, char *name, size_t len, char **ptr, size_t *plen) { iterator_t itr = NULL; - + int rc = 1; + list_get_iterator (ctx->values, &itr); for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) { @@ -163,6 +172,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, p = strchr (item, '='); if (p - item == len && strncasecmp (item, name, len) == 0) { + rc = 0; *ptr = ++p; *plen = strlen (*ptr); if (**ptr == '"') @@ -174,6 +184,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, } } iterator_destroy (&itr); + return rc; } static void @@ -239,11 +250,16 @@ expand_string (struct mime_context *ct, char **pstr) case '{': { size_t n; - char *q = ++p; + char *q; + + p += 2; + q = p; while (*p && *p != '}') p++; - mime_context_get_content_type_value (ct, q, p-q, &s, &n); - obstack_grow (&expand_stack, s, n); + if (mime_context_get_content_type_value (ct, + q, p-q, + &s, &n) == 0) + obstack_grow (&expand_stack, s, n); if (*p) p++; break; |