From 43d2ee6772394b54c0f8184bb7798d7dd2a8bd9e Mon Sep 17 00:00:00 2001 From: monsta Date: Mon, 1 Aug 2016 11:41:20 +0300 Subject: open-terminal: properly quote SSH arguments fixes problem with opening terminal in remote folders with ' or " in their names. adapted from: https://git.gnome.org/browse/nautilus-open-terminal/commit/?id=f1789425df12e054fa0b2407f7df861d98059599 --- open-terminal/caja-open-terminal.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/open-terminal/caja-open-terminal.c b/open-terminal/caja-open-terminal.c index 2186658..2f5efd1 100644 --- a/open-terminal/caja-open-terminal.c +++ b/open-terminal/caja-open-terminal.c @@ -221,6 +221,9 @@ append_sftp_info (char **terminal_exec, char *host_name, *path, *user_name; char *user_host, *cmd, *quoted_cmd; char *host_port_switch; + char *quoted_path; + char *remote_cmd; + char *quoted_remote_cmd; guint host_port; g_assert (terminal_exec != NULL); @@ -247,7 +250,11 @@ append_sftp_info (char **terminal_exec, user_host = g_strdup (host_name); } - cmd = g_strdup_printf ("ssh %s %s -t \"cd \'%s\' && $SHELL -l\"", user_host, host_port_switch, path); + quoted_path = g_shell_quote (path); + remote_cmd = g_strdup_printf ("cd %s && $SHELL -l", quoted_path); + quoted_remote_cmd = g_shell_quote (remote_cmd); + + cmd = g_strdup_printf ("ssh %s %s -t %s", user_host, host_port_switch, quoted_remote_cmd); quoted_cmd = g_shell_quote (cmd); g_free (cmd); @@ -259,7 +266,10 @@ append_sftp_info (char **terminal_exec, g_free (user_name); g_free (host_port_switch); g_free (path); + g_free (quoted_path); + g_free (remote_cmd); + g_free (quoted_remote_cmd); g_free (quoted_cmd); g_free (user_host); g_object_unref (vfs_uri); -- cgit v1.2.1