Fix minor inconsistencies
Showing
2 changed files
with
25 additions
and
10 deletions
... | @@ -335,7 +335,7 @@ get_content_type (mu_header_t hdr, mu_content_type_t *ctp, char const *dfl) | ... | @@ -335,7 +335,7 @@ get_content_type (mu_header_t hdr, mu_content_type_t *ctp, char const *dfl) |
335 | int rc; | 335 | int rc; |
336 | char *buffer = NULL; | 336 | char *buffer = NULL; |
337 | 337 | ||
338 | rc = mu_header_aget_value (hdr, MU_HEADER_CONTENT_TYPE, &buffer); | 338 | rc = mu_header_aget_value_unfold (hdr, MU_HEADER_CONTENT_TYPE, &buffer); |
339 | if (rc == 0) | 339 | if (rc == 0) |
340 | { | 340 | { |
341 | rc = mu_content_type_parse (buffer, ctp); | 341 | rc = mu_content_type_parse (buffer, ctp); | ... | ... |
1 | /* Content-Type (RFC 2045) parser for GNU Mailutils | ||
2 | Copyright (C) 2016 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License as published by | ||
6 | the Free Software Foundation; either version 3, or (at your option) | ||
7 | any later version. | ||
8 | |||
9 | GNU Mailutils is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ | ||
16 | |||
1 | #if HAVE_CONFIG_H | 17 | #if HAVE_CONFIG_H |
2 | # include <config.h> | 18 | # include <config.h> |
3 | #endif | 19 | #endif |
... | @@ -53,6 +69,10 @@ parse_type (const char *input, mu_content_type_t ct) | ... | @@ -53,6 +69,10 @@ parse_type (const char *input, mu_content_type_t ct) |
53 | return parse_subtype (input + i + 1, ct); | 69 | return parse_subtype (input + i + 1, ct); |
54 | } | 70 | } |
55 | 71 | ||
72 | static char tspecials[] = "()<>@,;:\\\"/[]?="; | ||
73 | |||
74 | #define ISTOKEN(c) ((unsigned char)(c) > ' ' && !strchr (tspecials, c)) | ||
75 | |||
56 | static int | 76 | static int |
57 | parse_subtype (const char *input, mu_content_type_t ct) | 77 | parse_subtype (const char *input, mu_content_type_t ct) |
58 | { | 78 | { |
... | @@ -60,8 +80,7 @@ parse_subtype (const char *input, mu_content_type_t ct) | ... | @@ -60,8 +80,7 @@ parse_subtype (const char *input, mu_content_type_t ct) |
60 | 80 | ||
61 | for (i = 0; !(input[i] == 0 || input[i] == ';'); i++) | 81 | for (i = 0; !(input[i] == 0 || input[i] == ';'); i++) |
62 | { | 82 | { |
63 | if (input[i] == 0 | 83 | if (!ISTOKEN (input[i])) |
64 | || !(mu_isalnum (input[i]) || input[i] == '-' || input[i] == '_')) | ||
65 | return MU_ERR_PARSE; | 84 | return MU_ERR_PARSE; |
66 | } | 85 | } |
67 | ct->subtype = malloc (i); | 86 | ct->subtype = malloc (i); |
... | @@ -86,7 +105,7 @@ parse_params (const char *input, mu_content_type_t ct) | ... | @@ -86,7 +105,7 @@ parse_params (const char *input, mu_content_type_t ct) |
86 | 105 | ||
87 | while (*input == ';') | 106 | while (*input == ';') |
88 | { | 107 | { |
89 | input = mu_str_skip_class (input + 1, MU_CTYPE_BLANK); | 108 | input = mu_str_skip_class (input + 1, MU_CTYPE_SPACE); |
90 | rc = parse_param (&input, ct); | 109 | rc = parse_param (&input, ct); |
91 | if (rc) | 110 | if (rc) |
92 | return rc; | 111 | return rc; |
... | @@ -94,7 +113,7 @@ parse_params (const char *input, mu_content_type_t ct) | ... | @@ -94,7 +113,7 @@ parse_params (const char *input, mu_content_type_t ct) |
94 | 113 | ||
95 | if (*input) | 114 | if (*input) |
96 | { | 115 | { |
97 | input = mu_str_skip_class (input, MU_CTYPE_BLANK); | 116 | input = mu_str_skip_class (input, MU_CTYPE_SPACE); |
98 | ct->trailer = strdup (input); | 117 | ct->trailer = strdup (input); |
99 | if (!ct->trailer) | 118 | if (!ct->trailer) |
100 | return ENOMEM; | 119 | return ENOMEM; |
... | @@ -103,10 +122,6 @@ parse_params (const char *input, mu_content_type_t ct) | ... | @@ -103,10 +122,6 @@ parse_params (const char *input, mu_content_type_t ct) |
103 | return rc; | 122 | return rc; |
104 | } | 123 | } |
105 | 124 | ||
106 | static char tspecials[] = "()<>@,;:\\\"/[]?="; | ||
107 | |||
108 | #define ISTOKEN(c) ((unsigned char)(c) > ' ' && !strchr (tspecials, c)) | ||
109 | |||
110 | static int | 125 | static int |
111 | parse_param (const char **input_ptr, mu_content_type_t ct) | 126 | parse_param (const char **input_ptr, mu_content_type_t ct) |
112 | { | 127 | { |
... | @@ -205,7 +220,7 @@ mu_content_type_parse (const char *input, mu_content_type_t *retct) | ... | @@ -205,7 +220,7 @@ mu_content_type_parse (const char *input, mu_content_type_t *retct) |
205 | if (!ct) | 220 | if (!ct) |
206 | return errno; | 221 | return errno; |
207 | 222 | ||
208 | rc = parse_type (mu_str_skip_class (input, MU_CTYPE_BLANK), ct); | 223 | rc = parse_type (mu_str_skip_class (input, MU_CTYPE_SPACE), ct); |
209 | if (rc) | 224 | if (rc) |
210 | mu_content_type_destroy (&ct); | 225 | mu_content_type_destroy (&ct); |
211 | else | 226 | else | ... | ... |
-
Please register or sign in to post a comment