summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2017-10-19 22:35:32 +0200
committerLinus Färnstrand <linus@mullvad.net>2017-10-20 08:50:23 +0200
commit25644538dee35ab40653a8f63cdf8425aeb35e57 (patch)
treefe96da4d2e159815835d10c002dfb66bcd64db11
parent801aba750a7e282ce965ae99ac26ae0006f579b3 (diff)
downloadmullvadvpn-25644538dee35ab40653a8f63cdf8425aeb35e57.tar.xz
mullvadvpn-25644538dee35ab40653a8f63cdf8425aeb35e57.zip
Replace own shell_escape with external lib
-rw-r--r--Cargo.lock7
-rw-r--r--talpid-core/Cargo.toml1
-rw-r--r--talpid-core/src/lib.rs1
-rw-r--r--talpid-core/src/process/openvpn.rs14
4 files changed, 12 insertions, 11 deletions
diff --git a/Cargo.lock b/Cargo.lock
index bfaa983231..f080a8e078 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1091,6 +1091,11 @@ dependencies = [
]
[[package]]
+name = "shell-escape"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "shell32-sys"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1223,6 +1228,7 @@ dependencies = [
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"openvpn-plugin 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pfctl 0.1.0 (git+https://github.com/mullvad/pfctl-rs?rev=3c8f5f839fa4051fda2f6c07ab7469c25986426b)",
+ "shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"socket-relay 0.1.0",
"talpid-ipc 0.1.0",
"talpid-types 0.1.0",
@@ -1646,6 +1652,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum serde_json 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ee28c1d94a7745259b767ca9e5b95d55bafbd3205ca3acb978cad84a6ed6bc62"
"checksum sha1 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cc30b1e1e8c40c121ca33b86c23308a090d19974ef001b4bf6e61fd1a0fb095c"
"checksum shared_child 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcd5e483b3475af9bc2a35311c2f3bbf0bd98fde91410ab15a0d4ba3c3127b4e"
+"checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8"
"checksum shell32-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72f20b8f3c060374edb8046591ba28f62448c369ccbdc7b02075103fb3a9e38d"
"checksum simple-signal 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c1eb01a0c2d12db9e52684e73038eac812494e5937571ae2631f5cf53dc56687"
"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23"
diff --git a/talpid-core/Cargo.toml b/talpid-core/Cargo.toml
index a811c911a4..1c04bdacef 100644
--- a/talpid-core/Cargo.toml
+++ b/talpid-core/Cargo.toml
@@ -13,6 +13,7 @@ jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc", tag = "v7.1.1"
lazy_static = "0.2"
log = "0.3"
uuid = { version = "0.5", features = ["v4"] }
+shell-escape = "0.1"
openvpn-plugin = { version = "0.3", features = ["serde"] }
talpid-ipc = { path = "../talpid-ipc" }
diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs
index da6c49c580..1af5587def 100644
--- a/talpid-core/src/lib.rs
+++ b/talpid-core/src/lib.rs
@@ -22,6 +22,7 @@ extern crate error_chain;
extern crate jsonrpc_core;
#[macro_use]
extern crate jsonrpc_macros;
+extern crate shell_escape;
extern crate uuid;
extern crate openvpn_plugin;
diff --git a/talpid-core/src/process/openvpn.rs b/talpid-core/src/process/openvpn.rs
index 0eb5ec953e..ec0487c4bd 100644
--- a/talpid-core/src/process/openvpn.rs
+++ b/talpid-core/src/process/openvpn.rs
@@ -4,6 +4,7 @@ use std::ffi::{OsStr, OsString};
use std::fmt;
use std::path::{Path, PathBuf};
+use shell_escape;
use talpid_types::net;
static BASE_ARGUMENTS: &[&[&str]] = &[
@@ -189,24 +190,15 @@ impl fmt::Display for OpenVpnCommand {
/// Format the program and arguments of an `OpenVpnCommand` for display. Any non-utf8 data
/// is lossily converted using the utf8 replacement character.
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- shell_escape(fmt, &self.openvpn_bin.to_string_lossy())?;
+ fmt.write_str(&shell_escape::escape(self.openvpn_bin.to_string_lossy()))?;
for arg in &self.get_arguments() {
fmt.write_str(" ")?;
- shell_escape(fmt, &arg.to_string_lossy())?;
+ fmt.write_str(&shell_escape::escape(arg.to_string_lossy()))?;
}
Ok(())
}
}
-fn shell_escape(fmt: &mut fmt::Formatter, arg: &str) -> fmt::Result {
- let quote = if arg.contains(char::is_whitespace) {
- "\""
- } else {
- ""
- };
- write!(fmt, "{}{}{}", quote, arg, quote)
-}
-
#[cfg(test)]
mod tests {