From f6fed7328b288782ffd7dcfd1b7e05c6b390e453 Mon Sep 17 00:00:00 2001 From: Valentin Haudiquet Date: Wed, 16 Sep 2026 01:24:02 +0200 Subject: [PATCH] pull: reject malformed --ppa values instead of silently using the archive A --ppa value that was not exactly 'user/name' (full URL, extra segment, empty halves) made base_url None and pulled the package from the main archive without any warning. Error out naming the expected format instead, and document the format in --help. --- src/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index ff425b7..2a68a73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,7 @@ fn main() { ) .arg(arg!(-v --version "Target package version").required(false)) .arg(arg!(--archive "Only use the archive to download package source, not git").required(false)) - .arg(arg!(--ppa "Download the package from a specific PPA").required(false)) + .arg(arg!(--ppa "Download the package from a specific PPA (format: user/ppa_name)").required(false)) .arg(arg!(--repository "Download the package from an external flat repository, given as its full suite URL (e.g. https://pkg.noctalia.dev/deb/resolute/)").required(false) .conflicts_with("ppa")) .arg(arg!(-p --pocket "Target package distribution pocket (updates, security, proposed)").required(false)) @@ -152,14 +152,14 @@ fn main() { let (pb, progress_callback) = pkh::ui::create_progress_bar(&multi); // Convert PPA to base URL if provided - let base_url = ppa.and_then(|ppa_str| { + let base_url = ppa.map(|ppa_str| { // PPA format: user/ppa_name let parts: Vec<&str> = ppa_str.split('/').collect(); - if parts.len() == 2 { - Some(pkh::package_info::ppa_to_base_url(parts[0], parts[1])) - } else { - None + if parts.len() != 2 || parts[0].is_empty() || parts[1].is_empty() { + error!("Invalid PPA format: '{}'. Expected: user/ppa_name", ppa_str); + std::process::exit(1); } + pkh::package_info::ppa_to_base_url(parts[0], parts[1]) }); // Since pull is async, we need to block on it