summaryrefslogtreecommitdiff
path: root/open-terminal/caja-open-terminal.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-08-01 11:41:20 +0300
committermonsta <[email protected]>2016-08-01 11:41:20 +0300
commit43d2ee6772394b54c0f8184bb7798d7dd2a8bd9e (patch)
tree8e1eba84ce086de58484ed38c626b24c17c6027f /open-terminal/caja-open-terminal.c
parent489c47adfa9beed22d589e45c6737194575d46e6 (diff)
downloadcaja-extensions-43d2ee6772394b54c0f8184bb7798d7dd2a8bd9e.tar.bz2
caja-extensions-43d2ee6772394b54c0f8184bb7798d7dd2a8bd9e.tar.xz
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
Diffstat (limited to 'open-terminal/caja-open-terminal.c')
-rw-r--r--open-terminal/caja-open-terminal.c12
1 files changed, 11 insertions, 1 deletions
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);