Skip to content

Commit

Permalink
fix(git-transport): Use single quotes for ssh path arg
Browse files Browse the repository at this point in the history
Git uses this method of quoting args for SSH transport too
Some Git SSH servers require this method to be used (eg. BitBucket)
  • Loading branch information
exactly-one-kas authored and Byron committed Feb 2, 2023
1 parent 03647fc commit acb4c17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions git-transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ git-url = { version = "^0.13.1", path = "../git-url" }
git-sec = { version = "^0.6.1", path = "../git-sec" }
git-packetline = { version = "^0.14.1", path = "../git-packetline" }
git-credentials = { version = "^0.9.0", path = "../git-credentials", optional = true }
git-quote = { version = "^0.4.0", path = "../git-quote" }

serde = { version = "1.0.114", optional = true, default-features = false, features = ["std", "derive"]}
bstr = { version = "1.0.1", default-features = false, features = ["std", "unicode"] }
Expand Down
7 changes: 6 additions & 1 deletion git-transport/src/client/blocking_io/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use std::{

use bstr::{io::BufReadExt, BStr, BString, ByteSlice};

use git_quote::to_single_quoted;

use crate::{
client::{self, git, ssh, MessageKind, RequestWriter, SetServiceResponse, WriteMode},
Protocol, Service,
Expand Down Expand Up @@ -215,8 +217,11 @@ impl client::Transport for SpawnProcessOnDemand {
cmd.stdout = Stdio::piped();
if self.ssh_cmd.is_some() {
cmd.args.push(service.as_str().into());
cmd.args
.push(to_single_quoted(self.path.as_ref()).to_os_str_lossy().into_owned());
} else {
cmd.args.push(self.path.to_os_str_lossy().into_owned());
}
cmd.args.push(self.path.to_os_str_lossy().into_owned());

let mut cmd = std::process::Command::from(cmd);
for env_to_remove in ENV_VARS_TO_REMOVE {
Expand Down

0 comments on commit acb4c17

Please sign in to comment.