From fd144c02abd36a29e07dc31e766ca2b14bdfac65 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 17 Jul 2012 09:48:00 +0200 Subject: [PATCH] parse: only escape spaces outside of quotes When we escape spaces to keep arguments together, only escape when the space is outside a "" string. See https://bugzilla.gnome.org/show_bug.cgi?id=673319 --- gst/gstparse.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gst/gstparse.c b/gst/gstparse.c index 1077cd83bf..97f3ca722d 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -175,14 +175,21 @@ static gchar * _gst_parse_escape (const gchar * str) { GString *gstr = NULL; + gboolean in_quotes; g_return_val_if_fail (str != NULL, NULL); gstr = g_string_sized_new (strlen (str)); + in_quotes = FALSE; + while (*str) { - if (*str == ' ') + if (*str == '"' && (!in_quotes || (in_quotes && *(str - 1) != '\\'))) + in_quotes = !in_quotes; + + if (*str == ' ' && !in_quotes) g_string_append_c (gstr, '\\'); + g_string_append_c (gstr, *str); str++; } @@ -244,6 +251,7 @@ gst_parse_launchv_full (const gchar ** argv, GstParseContext * context, argvp = argv; while (*argvp) { arg = *argvp; + GST_DEBUG ("eascaping argument %s", arg); tmp = _gst_parse_escape (arg); g_string_append (str, tmp); g_free (tmp);