fix(#11): validate RAW file format before processing

This commit is contained in:
opencode 2026-07-05 14:50:03 +00:00
parent c883e4d26a
commit 6470ed153d

View File

@ -179,6 +179,29 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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
let output_path = sanitize_path(&args.output, false).map_err(|e| {
eprintln!("Error: {}", e);