(mime_context_fill): Remove leading whitespace
when preparing lists. (mime_context_get_content_type_value): Return integer code. (expand_string): Fixed expansion of %{name}
Showing
1 changed file
with
23 additions
and
7 deletions
... | @@ -78,7 +78,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, | ... | @@ -78,7 +78,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, |
78 | 78 | ||
79 | list_create (&ctx->values); | 79 | list_create (&ctx->values); |
80 | while ((p = strtok_r (NULL, ";", &sp))) | 80 | while ((p = strtok_r (NULL, ";", &sp))) |
81 | list_append (ctx->values, p); | 81 | { |
82 | while (*p && isspace (*p)) | ||
83 | p++; | ||
84 | list_append (ctx->values, p); | ||
85 | } | ||
82 | 86 | ||
83 | if (no_ask) | 87 | if (no_ask) |
84 | { | 88 | { |
... | @@ -86,7 +90,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, | ... | @@ -86,7 +90,11 @@ mime_context_fill (struct mime_context *ctx, const char *file, |
86 | list_create (&ctx->no_ask_types); | 90 | list_create (&ctx->no_ask_types); |
87 | for (p = strtok_r (ctx->no_ask_str, ",", &sp); p; | 91 | for (p = strtok_r (ctx->no_ask_str, ",", &sp); p; |
88 | p = strtok_r (NULL, ",", &sp)) | 92 | p = strtok_r (NULL, ",", &sp)) |
89 | list_append (ctx->no_ask_types, p); | 93 | { |
94 | while (*p && isspace (*p)) | ||
95 | p++; | ||
96 | list_append (ctx->no_ask_types, p); | ||
97 | } | ||
90 | } | 98 | } |
91 | } | 99 | } |
92 | 100 | ||
... | @@ -147,13 +155,14 @@ mime_context_get_input (struct mime_context *ctx, stream_t *pinput) | ... | @@ -147,13 +155,14 @@ mime_context_get_input (struct mime_context *ctx, stream_t *pinput) |
147 | *pinput = ctx->input; | 155 | *pinput = ctx->input; |
148 | } | 156 | } |
149 | 157 | ||
150 | static void | 158 | static int |
151 | mime_context_get_content_type_value (struct mime_context *ctx, | 159 | mime_context_get_content_type_value (struct mime_context *ctx, |
152 | char *name, size_t len, | 160 | char *name, size_t len, |
153 | char **ptr, size_t *plen) | 161 | char **ptr, size_t *plen) |
154 | { | 162 | { |
155 | iterator_t itr = NULL; | 163 | iterator_t itr = NULL; |
156 | 164 | int rc = 1; | |
165 | |||
157 | list_get_iterator (ctx->values, &itr); | 166 | list_get_iterator (ctx->values, &itr); |
158 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) | 167 | for (iterator_first (itr); !iterator_is_done (itr); iterator_next (itr)) |
159 | { | 168 | { |
... | @@ -163,6 +172,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, | ... | @@ -163,6 +172,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, |
163 | p = strchr (item, '='); | 172 | p = strchr (item, '='); |
164 | if (p - item == len && strncasecmp (item, name, len) == 0) | 173 | if (p - item == len && strncasecmp (item, name, len) == 0) |
165 | { | 174 | { |
175 | rc = 0; | ||
166 | *ptr = ++p; | 176 | *ptr = ++p; |
167 | *plen = strlen (*ptr); | 177 | *plen = strlen (*ptr); |
168 | if (**ptr == '"') | 178 | if (**ptr == '"') |
... | @@ -174,6 +184,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, | ... | @@ -174,6 +184,7 @@ mime_context_get_content_type_value (struct mime_context *ctx, |
174 | } | 184 | } |
175 | } | 185 | } |
176 | iterator_destroy (&itr); | 186 | iterator_destroy (&itr); |
187 | return rc; | ||
177 | } | 188 | } |
178 | 189 | ||
179 | static void | 190 | static void |
... | @@ -239,11 +250,16 @@ expand_string (struct mime_context *ct, char **pstr) | ... | @@ -239,11 +250,16 @@ expand_string (struct mime_context *ct, char **pstr) |
239 | case '{': | 250 | case '{': |
240 | { | 251 | { |
241 | size_t n; | 252 | size_t n; |
242 | char *q = ++p; | 253 | char *q; |
254 | |||
255 | p += 2; | ||
256 | q = p; | ||
243 | while (*p && *p != '}') | 257 | while (*p && *p != '}') |
244 | p++; | 258 | p++; |
245 | mime_context_get_content_type_value (ct, q, p-q, &s, &n); | 259 | if (mime_context_get_content_type_value (ct, |
246 | obstack_grow (&expand_stack, s, n); | 260 | q, p-q, |
261 | &s, &n) == 0) | ||
262 | obstack_grow (&expand_stack, s, n); | ||
247 | if (*p) | 263 | if (*p) |
248 | p++; | 264 | p++; |
249 | break; | 265 | break; | ... | ... |
-
Please register or sign in to post a comment