[PATCH 2/4] git_connect: avoid quoting the path on the command line when it's not necessary
- From
Mike Hommey <mh@glandium.org>
- Date
- Apr 28, 2016, 14:12 UTC
- Message-ID
- <1461852759-28429-3-git-send-email-mh@glandium.org>
- In-Reply-To
- <1461852759-28429-1-git-send-email-mh@glandium.org>
Some remote systems can employ restricted shells that aren't very smart with quotes, so avoid quoting when it's not strictly necessary.
The list of "safe" characters comes from Mercurial's shell quoting function used for its ssh client side. There likely are more that could be added to the list.
Signed-off-by: Mike Hommey <mh@glandium.org> --- connect.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/connect.c b/connect.c index 96c8c1d..919bf9e 100644 --- a/connect.c +++ b/connect.c @@ -668,6 +668,17 @@ static void prepare_connect_command(struct strbuf *cmd, const char *prog, strbuf_addstr(cmd, prog); strbuf_addch(cmd, ' '); } + if (quote) { + const char *p; + for (p = path; *p; p++) { + if (!isalnum(*p) && *p != '@' && *p != '%' && + *p != '_' && *p != '+' && *p != '=' && *p != ':' && + *p != ',' && *p != '.' && *p != '/' && *p != '-') + break; + } + if (!*p) + quote = 0; + } if (quote) sq_quote_buf(cmd, path); else
-- 2.8.1.5.g18c8a48