fix(#11): validate RAW file format before processing
This commit is contained in:
parent
c883e4d26a
commit
6470ed153d
23
src/main.rs
23
src/main.rs
@ -179,6 +179,29 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
e
|
e
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
// Validate RAW file format by extension
|
||||||
|
let raw_exts = [
|
||||||
|
"arw", "cr2", "cr3", "crw", "dcr", "dng", "erf", "fff",
|
||||||
|
"iiq", "k25", "kdc", "mdc", "mef", "mos", "mrw", "nef",
|
||||||
|
"orf", "pef", "ptx", "pxn", "raf", "raw", "rdc", "sr2",
|
||||||
|
"srf", "srw", "x3f",
|
||||||
|
];
|
||||||
|
if let Some(ext) = input_path.extension().and_then(|s| s.to_str()) {
|
||||||
|
let ext_lower = ext.to_lowercase();
|
||||||
|
if !raw_exts.contains(&ext_lower.as_str()) {
|
||||||
|
eprintln!(
|
||||||
|
"Error: '{}' is not a supported RAW format (extension: .{})",
|
||||||
|
input_path.display(),
|
||||||
|
ext_lower
|
||||||
|
);
|
||||||
|
eprintln!("Supported formats: {}", raw_exts.join(", "));
|
||||||
|
return Err("Unsupported file format".into());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eprintln!("Error: Input file has no extension: {}", input_path.display());
|
||||||
|
return Err("File has no extension".into());
|
||||||
|
}
|
||||||
|
|
||||||
// Sanitize and resolve output path
|
// Sanitize and resolve output path
|
||||||
let output_path = sanitize_path(&args.output, false).map_err(|e| {
|
let output_path = sanitize_path(&args.output, false).map_err(|e| {
|
||||||
eprintln!("Error: {}", e);
|
eprintln!("Error: {}", e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user