mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
Include a test involving consecutive backslashes followed by a non-escaped
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de> * tests/shell-test.c: Include a test involving consecutive backslashes followed by a non-escaped doublequote. * glib/gshell.c (tokenize_command_line): Count consecutive backslashes mod 2 to detect escaped doubleqotes. (#127306)
This commit is contained in:
parent
0611985dd9
commit
d2c7108828
@ -1,3 +1,11 @@
|
|||||||
|
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* tests/shell-test.c: Include a test involving consecutive
|
||||||
|
backslashes followed by a non-escaped doublequote.
|
||||||
|
|
||||||
|
* glib/gshell.c (tokenize_command_line): Count consecutive
|
||||||
|
backslashes mod 2 to detect escaped doubleqotes. (#127306)
|
||||||
|
|
||||||
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* tests/shell-test.c: Include a test involving consecutive
|
||||||
|
backslashes followed by a non-escaped doublequote.
|
||||||
|
|
||||||
|
* glib/gshell.c (tokenize_command_line): Count consecutive
|
||||||
|
backslashes mod 2 to detect escaped doubleqotes. (#127306)
|
||||||
|
|
||||||
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* tests/shell-test.c: Include a test involving consecutive
|
||||||
|
backslashes followed by a non-escaped doublequote.
|
||||||
|
|
||||||
|
* glib/gshell.c (tokenize_command_line): Count consecutive
|
||||||
|
backslashes mod 2 to detect escaped doubleqotes. (#127306)
|
||||||
|
|
||||||
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* tests/shell-test.c: Include a test involving consecutive
|
||||||
|
backslashes followed by a non-escaped doublequote.
|
||||||
|
|
||||||
|
* glib/gshell.c (tokenize_command_line): Count consecutive
|
||||||
|
backslashes mod 2 to detect escaped doubleqotes. (#127306)
|
||||||
|
|
||||||
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Sat Jul 31 20:33:07 2004 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* tests/shell-test.c: Include a test involving consecutive
|
||||||
|
backslashes followed by a non-escaped doublequote.
|
||||||
|
|
||||||
|
* glib/gshell.c (tokenize_command_line): Count consecutive
|
||||||
|
backslashes mod 2 to detect escaped doubleqotes. (#127306)
|
||||||
|
|
||||||
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
2004-07-30 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
* glib/gconvert.c (g_unescape_uri_string): Don't validate
|
||||||
|
@ -413,8 +413,10 @@ tokenize_command_line (const gchar *command_line,
|
|||||||
const gchar *p;
|
const gchar *p;
|
||||||
GString *current_token = NULL;
|
GString *current_token = NULL;
|
||||||
GSList *retval = NULL;
|
GSList *retval = NULL;
|
||||||
|
gboolean quoted;;
|
||||||
|
|
||||||
current_quote = '\0';
|
current_quote = '\0';
|
||||||
|
quoted = FALSE;
|
||||||
p = command_line;
|
p = command_line;
|
||||||
|
|
||||||
while (*p)
|
while (*p)
|
||||||
@ -452,7 +454,7 @@ tokenize_command_line (const gchar *command_line,
|
|||||||
{
|
{
|
||||||
if (*p == current_quote &&
|
if (*p == current_quote &&
|
||||||
/* check that it isn't an escaped double quote */
|
/* check that it isn't an escaped double quote */
|
||||||
!(current_quote == '"' && p != command_line && *(p - 1) == '\\'))
|
!(current_quote == '"' && quoted))
|
||||||
{
|
{
|
||||||
/* close the quote */
|
/* close the quote */
|
||||||
current_quote = '\0';
|
current_quote = '\0';
|
||||||
@ -516,6 +518,14 @@ tokenize_command_line (const gchar *command_line,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We need to count consecutive backslashes mod 2,
|
||||||
|
* to detect escaped doublequotes.
|
||||||
|
*/
|
||||||
|
if (*p != '\\')
|
||||||
|
quoted = FALSE;
|
||||||
|
else
|
||||||
|
quoted = !quoted;
|
||||||
|
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ test_command_lines[] =
|
|||||||
/* 9 */ "foo \\\" la la la",
|
/* 9 */ "foo \\\" la la la",
|
||||||
/* 10 */ "foo \\ foo woo woo\\ ",
|
/* 10 */ "foo \\ foo woo woo\\ ",
|
||||||
/* 11 */ "foo \"yada yada \\$\\\"\"",
|
/* 11 */ "foo \"yada yada \\$\\\"\"",
|
||||||
|
/* 12 */ "foo \"c:\\\\\"",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ static const gchar *result8[] = { "foo", "", "", NULL };
|
|||||||
static const gchar *result9[] = { "foo", "\"", "la", "la", "la", NULL };
|
static const gchar *result9[] = { "foo", "\"", "la", "la", "la", NULL };
|
||||||
static const gchar *result10[] = { "foo", " foo", "woo", "woo ", NULL };
|
static const gchar *result10[] = { "foo", " foo", "woo", "woo ", NULL };
|
||||||
static const gchar *result11[] = { "foo", "yada yada $\"", NULL };
|
static const gchar *result11[] = { "foo", "yada yada $\"", NULL };
|
||||||
|
static const gchar *result12[] = { "foo", "c:\\", NULL };
|
||||||
|
|
||||||
static const TestResult
|
static const TestResult
|
||||||
correct_results[] =
|
correct_results[] =
|
||||||
@ -86,7 +88,8 @@ correct_results[] =
|
|||||||
{ G_N_ELEMENTS (result8) - 1, result8 },
|
{ G_N_ELEMENTS (result8) - 1, result8 },
|
||||||
{ G_N_ELEMENTS (result9) - 1, result9 },
|
{ G_N_ELEMENTS (result9) - 1, result9 },
|
||||||
{ G_N_ELEMENTS (result10) - 1, result10 },
|
{ G_N_ELEMENTS (result10) - 1, result10 },
|
||||||
{ G_N_ELEMENTS (result11) - 1, result11 }
|
{ G_N_ELEMENTS (result11) - 1, result11 },
|
||||||
|
{ G_N_ELEMENTS (result12) - 1, result12 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user