Commit 07be38a0 07be38a0eec5c9ea00a74a023bc3e8e98d98d715 by Sergey Poznyakoff

Fix minor inconsistencies

1 parent 81973969
......@@ -335,7 +335,7 @@ get_content_type (mu_header_t hdr, mu_content_type_t *ctp, char const *dfl)
int rc;
char *buffer = NULL;
rc = mu_header_aget_value (hdr, MU_HEADER_CONTENT_TYPE, &buffer);
rc = mu_header_aget_value_unfold (hdr, MU_HEADER_CONTENT_TYPE, &buffer);
if (rc == 0)
{
rc = mu_content_type_parse (buffer, ctp);
......
/* Content-Type (RFC 2045) parser for GNU Mailutils
Copyright (C) 2016 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Mailutils is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
......@@ -53,6 +69,10 @@ parse_type (const char *input, mu_content_type_t ct)
return parse_subtype (input + i + 1, ct);
}
static char tspecials[] = "()<>@,;:\\\"/[]?=";
#define ISTOKEN(c) ((unsigned char)(c) > ' ' && !strchr (tspecials, c))
static int
parse_subtype (const char *input, mu_content_type_t ct)
{
......@@ -60,8 +80,7 @@ parse_subtype (const char *input, mu_content_type_t ct)
for (i = 0; !(input[i] == 0 || input[i] == ';'); i++)
{
if (input[i] == 0
|| !(mu_isalnum (input[i]) || input[i] == '-' || input[i] == '_'))
if (!ISTOKEN (input[i]))
return MU_ERR_PARSE;
}
ct->subtype = malloc (i);
......@@ -86,7 +105,7 @@ parse_params (const char *input, mu_content_type_t ct)
while (*input == ';')
{
input = mu_str_skip_class (input + 1, MU_CTYPE_BLANK);
input = mu_str_skip_class (input + 1, MU_CTYPE_SPACE);
rc = parse_param (&input, ct);
if (rc)
return rc;
......@@ -94,7 +113,7 @@ parse_params (const char *input, mu_content_type_t ct)
if (*input)
{
input = mu_str_skip_class (input, MU_CTYPE_BLANK);
input = mu_str_skip_class (input, MU_CTYPE_SPACE);
ct->trailer = strdup (input);
if (!ct->trailer)
return ENOMEM;
......@@ -103,10 +122,6 @@ parse_params (const char *input, mu_content_type_t ct)
return rc;
}
static char tspecials[] = "()<>@,;:\\\"/[]?=";
#define ISTOKEN(c) ((unsigned char)(c) > ' ' && !strchr (tspecials, c))
static int
parse_param (const char **input_ptr, mu_content_type_t ct)
{
......@@ -205,7 +220,7 @@ mu_content_type_parse (const char *input, mu_content_type_t *retct)
if (!ct)
return errno;
rc = parse_type (mu_str_skip_class (input, MU_CTYPE_BLANK), ct);
rc = parse_type (mu_str_skip_class (input, MU_CTYPE_SPACE), ct);
if (rc)
mu_content_type_destroy (&ct);
else
......