mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 11:12:25 +00:00
fix name escaping issue in Cargo.toml (#1635) and added corresponding
test
This commit is contained in:
parent
3090cc3151
commit
284c0ef974
|
@ -13,6 +13,8 @@ use term::color::BLACK;
|
|||
use util::{GitRepo, HgRepo, CargoResult, human, ChainError, internal};
|
||||
use util::Config;
|
||||
|
||||
use toml;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum VersionControl { Git, Hg, NoVcs }
|
||||
|
||||
|
@ -149,8 +151,8 @@ fn mk(config: &Config, path: &Path, name: &str,
|
|||
r#"[package]
|
||||
name = "{}"
|
||||
version = "0.1.0"
|
||||
authors = ["{}"]
|
||||
"#, name, author).as_bytes()));
|
||||
authors = [{}]
|
||||
"#, name, toml::Value::String(author)).as_bytes()));
|
||||
|
||||
try!(fs::create_dir(&path.join("src")));
|
||||
|
||||
|
|
|
@ -138,6 +138,20 @@ test!(finds_author_user {
|
|||
assert!(contents.contains(r#"authors = ["foo"]"#));
|
||||
});
|
||||
|
||||
test!(finds_author_user_escaped {
|
||||
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
|
||||
// the hierarchy
|
||||
let td = TempDir::new("cargo").unwrap();
|
||||
assert_that(cargo_process("new").arg("foo").env("USER", "foo \"bar\"")
|
||||
.cwd(td.path().clone()),
|
||||
execs().with_status(0));
|
||||
|
||||
let toml = td.path().join("foo/Cargo.toml");
|
||||
let mut contents = String::new();
|
||||
File::open(&toml).unwrap().read_to_string(&mut contents).unwrap();
|
||||
assert!(contents.contains(r#"authors = ["foo \"bar\""]"#));
|
||||
});
|
||||
|
||||
test!(finds_author_username {
|
||||
// Use a temp dir to make sure we don't pick up .cargo/config somewhere in
|
||||
// the hierarchy
|
||||
|
|
Loading…
Reference in a new issue