Commit c09870d8 c09870d821d43dadfc6ebc9de143172fce358243 by Sergey Poznyakoff

Mail: fix parsing of arguments containing =.

* mail/util.c (util_do_command): Do not use = as a delimiter.
* mail/set.c (mail_set): = is no longer returned as a token.
* mail/setenv.c (mail_setenv): Likewise.
1 parent 17751e6b
......@@ -40,25 +40,24 @@ mail_set (int argc, char **argv)
for (i = 1; i < argc; i++)
{
if (!strncmp ("no", argv[i], 2))
char *value = strchr (argv[i], '=');
if (value)
*value++ = 0;
if (!strncmp ("no", argv[i], 2) && !value)
{
util_setenv (&argv[i][2], NULL, Mail_env_boolean, 1);
}
else if (i+1 < argc && argv[i+1][0] == '=')
else if (value)
{
int nval;
char *name = argv[i];
char *p;
i += 2;
if (i >= argc)
break;
nval = strtoul (argv[i], &p, 0);
nval = strtoul (value, &p, 0);
if (*p == 0)
util_setenv (name, &nval, Mail_env_number, 1);
util_setenv (argv[i], &nval, Mail_env_number, 1);
else
util_setenv (name, argv[i], Mail_env_string, 1);
util_setenv (argv[i], value, Mail_env_string, 1);
}
else
{
......
......@@ -39,21 +39,12 @@ mail_setenv (int argc, char **argv)
/* Note: POSIX requires that the argument to putenv become part
of the environment itself, hence the memory allocation. */
for (i = 1; i < argc;)
for (i = 1; i < argc; i++)
{
char *p;
if (i+1 < argc && argv[i+1][0] == '=')
{
asprintf (&p, "%s=%s", argv[i], argv[i+2]);
i += 3;
}
else
{
p = argv[i];
i++;
}
putenv (p);
char *value = strchr (argv[i], '=');
if (value)
*value++ = 0;
setenv (argv[i], value ? value : "", 1);
}
}
return 0;
......
......@@ -52,7 +52,6 @@ util_do_command (const char *c, ...)
const struct mail_command_entry *entry = NULL;
char *cmd = NULL;
va_list ap;
static const char *delim = "=";
va_start (ap, c);
status = vasprintf (&cmd, c, ap);
......@@ -82,7 +81,7 @@ util_do_command (const char *c, ...)
return 0;
}
if (mu_argcv_get (cmd, delim, NULL, &argc, &argv) == 0 && argc > 0)
if (mu_argcv_get (cmd, NULL, NULL, &argc, &argv) == 0 && argc > 0)
{
char *p;
......@@ -93,7 +92,7 @@ util_do_command (const char *c, ...)
{
asprintf (&p, "print %s", argv[0]);
mu_argcv_free (argc, argv);
mu_argcv_get (p, delim, NULL, &argc, &argv);
mu_argcv_get (p, NULL, NULL, &argc, &argv);
free (p);
}
......@@ -690,7 +689,7 @@ util_setenv (const char *variable, void *value, mail_env_data_t type,
abort();
}
}
/* Special handling for some variables */
if (strcmp (variable, "replyregex") == 0)
{
......