summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <thibault.saunier@osg.samsung.com>2016-09-14 14:32:19 -0300
committerThibault Saunier <thibault.saunier@osg.samsung.com>2016-09-14 18:29:58 -0300
commit244266a94ec9c341616bbfaa74dcb32f84dd6dc9 (patch)
treea4e35337c846ffff492ce073b596b4e37b5eb809
parente32a948868b2f15ede999045d824122d6ac6420a (diff)
ges-launch: Be a bit more agressive sanitizing arguments
Otherwise GstStructure might fail parsing some fields containing brackets https://bugzilla.gnome.org/show_bug.cgi?id=771434
-rw-r--r--tools/utils.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/utils.c b/tools/utils.c
index dd487831..0a950824 100644
--- a/tools/utils.c
+++ b/tools/utils.c
@@ -23,22 +23,31 @@
#include <gst/gst.h>
#include "utils.h"
+#define IS_ALPHANUM(c) (g_ascii_isalnum((c)) || ((c) == '-') || ((c) == '+'))
+
/* g_free after usage */
static gchar *
_sanitize_argument (gchar * arg)
{
+ gboolean has_non_alphanum = FALSE;
char *equal_index = strstr (arg, "=");
- char *space_index = strstr (arg, " ");
gchar *new_string, *tmp_string;
- if (!space_index)
+ for (tmp_string = arg; *tmp_string != '\0'; tmp_string++) {
+ if (!IS_ALPHANUM (*tmp_string)) {
+ has_non_alphanum = TRUE;
+
+ break;
+ }
+ }
+
+ if (!has_non_alphanum)
return g_strdup (arg);
- if (!equal_index || equal_index > space_index)
+ if (!equal_index)
return g_strdup_printf ("\"%s\"", arg);
tmp_string = new_string = g_malloc (sizeof (gchar) * (strlen (arg) + 3));
-
for (; *arg != '\0'; arg++) {
*tmp_string = *arg;
tmp_string += 1;