summaryrefslogtreecommitdiffhomepage
path: root/talpid-core/src
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 /talpid-core/src
parent801aba750a7e282ce965ae99ac26ae0006f579b3 (diff)
downloadmullvadvpn-25644538dee35ab40653a8f63cdf8425aeb35e57.tar.xz
mullvadvpn-25644538dee35ab40653a8f63cdf8425aeb35e57.zip
Replace own shell_escape with external lib
Diffstat (limited to 'talpid-core/src')
-rw-r--r--talpid-core/src/lib.rs1
-rw-r--r--talpid-core/src/process/openvpn.rs14
2 files changed, 4 insertions, 11 deletions
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 {