~ted/ubuntu-app-launch/pids-tools

« back to all changes in this revision

Viewing changes to helpers.c

Use shell escaping to ensure we can handle spaces. Fixes: https://bugs.launchpad.net/bugs/1229354.

Approved by Charles Kerr, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
static gchar *
287
287
build_file_list (const gchar * uri_list)
288
288
{
289
 
        /* TODO: Joining only with space could cause issues with breaking them
290
 
           back out.  We don't have any cases of more than one today.  But, this
291
 
           isn't good.
292
 
           https://bugs.launchpad.net/upstart-app-launch/+bug/1229354
293
 
           */
294
 
        gchar ** uri_split = g_strsplit(uri_list, " ", 0);
 
289
        gchar ** uri_split = NULL;
 
290
        if (!g_shell_parse_argv(uri_list, NULL, &uri_split, NULL)) {
 
291
                return g_strdup("");
 
292
        }
295
293
 
296
294
        GArray * outarray = g_array_new(TRUE, FALSE, sizeof(gchar *));
297
295
        g_array_set_clear_func(outarray, free_string);
322
320
                return;
323
321
        }
324
322
 
325
 
        /* TODO: Joining only with space could cause issues with breaking them
326
 
           back out.  We don't have any cases of more than one today.  But, this
327
 
           isn't good.
328
 
           https://bugs.launchpad.net/upstart-app-launch/+bug/1229354
329
 
           */
330
 
 
331
 
        gchar * first_uri = g_strdup(uri_list);
332
 
        gchar * first_space = g_utf8_strchr(first_uri, -1, ' ');
333
 
        
334
 
        if (first_space != NULL) {
335
 
                first_space[0] = '\0';
336
 
        }
337
 
 
338
 
        *single_uri = first_uri;
 
323
        gchar ** uri_split = NULL;
 
324
        if (!g_shell_parse_argv(uri_list, NULL, &uri_split, NULL)) {
 
325
                return;
 
326
        }
 
327
 
 
328
        if (uri_split[0] != NULL) {
 
329
                *single_uri = g_strdup(uri_split[0]);
 
330
        }
 
331
 
 
332
        g_strfreev(uri_split);
339
333
 
340
334
        return;
341
335
}
352
346
                return;
353
347
        }
354
348
 
355
 
        /* TODO: Joining only with space could cause issues with breaking them
356
 
           back out.  We don't have any cases of more than one today.  But, this
357
 
           isn't good.
358
 
           https://bugs.launchpad.net/upstart-app-launch/+bug/1229354
359
 
           */
360
 
 
361
 
        gchar * first_uri = g_strdup(uri_list);
362
 
        gchar * first_space = g_utf8_strchr(first_uri, -1, ' ');
363
 
        
364
 
        if (first_space != NULL) {
365
 
                first_space[0] = '\0';
 
349
        gchar ** uri_split = NULL;
 
350
        if (!g_shell_parse_argv(uri_list, NULL, &uri_split, NULL)) {
 
351
                return;
366
352
        }
367
353
 
368
354
        gchar * first_file = NULL;
369
 
        if (first_uri != NULL) {
370
 
                first_file = uri2file(first_uri);
 
355
        if (uri_split[0] != NULL) {
 
356
                first_file = uri2file(uri_split[0]);
371
357
        }
372
358
 
 
359
        g_strfreev(uri_split);
 
360
 
373
361
        if (first_file != NULL) {
374
362
                *single_file = first_file;
375
363
        }
455
443
                        g_array_append_val(outarray, skipchar);
456
444
                        break;
457
445
                case 'U':
458
 
                        /* TODO: Joining only with space could cause issues with breaking them
459
 
                           back out.  We don't have any cases of more than one today.  But, this
460
 
                           isn't good.
461
 
                           https://bugs.launchpad.net/upstart-app-launch/+bug/1229354
462
 
                           */
463
446
                        if (uri_list != NULL) {
464
447
                                g_array_append_val(outarray, uri_list);
465
448
                        }