Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions shell/ev-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,27 @@ ev_display_open_if_needed (const gchar *name)
}
#endif /* ENABLE_DBUS */

/*
* g_app_info_create_from_commandline() expands desktop entry field codes
* (%f, %u, ...) before splitting the arguments, even inside quotes, so "%"
* must be escaped for the value to reach the new instance unchanged.
*/
static gchar *
ev_spawn_quote_argument (const gchar *arg)
{
gchar *quoted;
gchar **parts;
gchar *escaped;

quoted = g_shell_quote (arg);
parts = g_strsplit (quoted, "%", -1);
escaped = g_strjoinv ("%%", parts);
g_strfreev (parts);
g_free (quoted);

return escaped;
}

static void
ev_spawn (const char *uri,
GdkScreen *screen,
Expand All @@ -238,7 +259,7 @@ ev_spawn (const char *uri,
if (dest) {
switch (ev_link_dest_get_dest_type (dest)) {
case EV_LINK_DEST_TYPE_PAGE_LABEL: {
gchar *quoted = g_shell_quote (ev_link_dest_get_page_label (dest));
gchar *quoted = ev_spawn_quote_argument (ev_link_dest_get_page_label (dest));
g_string_append_printf (cmd, " --page-label=%s", quoted);
g_free (quoted);
break;
Expand All @@ -248,7 +269,7 @@ ev_spawn (const char *uri,
ev_link_dest_get_page (dest) + 1);
break;
case EV_LINK_DEST_TYPE_NAMED: {
gchar *quoted = g_shell_quote (ev_link_dest_get_named_dest (dest));
gchar *quoted = ev_spawn_quote_argument (ev_link_dest_get_named_dest (dest));
g_string_append_printf (cmd, " --named-dest=%s", quoted);
g_free (quoted);
break;
Expand All @@ -260,7 +281,7 @@ ev_spawn (const char *uri,

/* Find string */
if (search_string) {
gchar *quoted = g_shell_quote (search_string);
gchar *quoted = ev_spawn_quote_argument (search_string);
g_string_append_printf (cmd, " --find=%s", quoted);
g_free (quoted);
}
Expand Down
Loading