MPD client: fix argument quoting
Alpine 3.20 Success
Details
Alpine 3.20 Success
Details
This commit is contained in:
parent
e78b410a6a
commit
8a8437634a
|
@ -1635,30 +1635,30 @@ mpd_client_on_ready (const struct pollfd *pfd, void *user_data)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
static bool
|
||||
mpd_client_must_quote_char (char c)
|
||||
{
|
||||
return (unsigned char) c <= ' ' || c == '"' || c == '\'';
|
||||
}
|
||||
|
||||
static bool
|
||||
mpd_client_must_quote (const char *s)
|
||||
{
|
||||
if (!*s)
|
||||
return true;
|
||||
for (; *s; s++)
|
||||
if (mpd_client_must_quote_char (*s))
|
||||
if ((unsigned char) *s <= ' ' || *s == '"' || *s == '\'')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
mpd_client_must_escape_in_quote (char c)
|
||||
{
|
||||
return c == '"' || c == '\'' || c == '\\';
|
||||
}
|
||||
|
||||
static void
|
||||
mpd_client_quote (const char *s, struct str *output)
|
||||
{
|
||||
str_append_c (output, '"');
|
||||
for (; *s; s++)
|
||||
{
|
||||
if (mpd_client_must_quote_char (*s))
|
||||
if (mpd_client_must_escape_in_quote (*s))
|
||||
str_append_c (output, '\\');
|
||||
str_append_c (output, *s);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue