Skip to content

Commit

Permalink
improvements: ensure that the additional manifest paths ends with `Ca…
Browse files Browse the repository at this point in the history
…rgo.toml`

Otherwise, one can point to another filename and get bugs.

Signed-off-by: Soc Virnyl Estela <[email protected]>
  • Loading branch information
uncomfyhalomacro committed Nov 17, 2024
1 parent 9fbb7e5 commit 37a9d48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cargo/src/cargo_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,12 @@ pub fn cargo_update(
}

if !dependent.trim().is_empty() {
if !dependent.ends_with("Cargo.toml") {
let msg =
format!("Expected a valid manifest filename. Got {}.", dependent,);
error!(?dependent, msg);
return Err(io::Error::new(io::ErrorKind::InvalidInput, msg));
}
info!("🏗️ Updating {} at {}.", crate_name, dependent);
let dependent_manifest_path = curdir.join(dependent).canonicalize()?;
default_options.push("--manifest-path".to_string());
Expand Down Expand Up @@ -411,6 +417,12 @@ pub fn cargo_update(
}

if !dependent.trim().is_empty() {
if !dependent.ends_with("Cargo.toml") {
let msg =
format!("Expected a valid manifest filename. Got {}.", dependent,);
error!(?dependent, msg);
return Err(io::Error::new(io::ErrorKind::InvalidInput, msg));
}
info!("🏗️ Updating {} at {}.", crate_name, dependent);
let dependent_manifest_path = curdir.join(dependent).canonicalize()?;
default_options.push("--manifest-path".to_string());
Expand Down
8 changes: 8 additions & 0 deletions cargo/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ pub fn run_cargo_vendor_home_registry(
}
let mut lockfiles: Vec<PathBuf> = Vec::new();
for manifest in &registry.manifest_path {
if !manifest.ends_with("Cargo.toml") {
let msg = format!(
"Expected a valid manifest filename. Got {}.",
manifest.display()
);
error!(?manifest, msg);
return Err(io::Error::new(io::ErrorKind::InvalidInput, msg));
}
let full_manifest_path = &custom_root.join(manifest);
let full_manifest_path_parent = full_manifest_path.parent().unwrap_or(setup_workdir);
if full_manifest_path.is_file() {
Expand Down

0 comments on commit 37a9d48

Please sign in to comment.