mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 14:07:34 -06:00
CLI-HOSTILE: render --set refuses inf / NaN instead of dropping the value
`inf`, `NaN` and `1e999` parse as f64 but serialize to JSON null, so the control was silently skipped and the photo rendered without the requested edit. They are now an error. Hostile-input check added to the render subcommand test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
387bed199f
commit
2085426230
@@ -683,7 +683,9 @@ fn render(args: &[String]) -> Result<(), String> {
|
||||
"--set" => {
|
||||
let kv = take_value(args, &mut i, "--set")?;
|
||||
let (k, v) = kv.split_once('=').ok_or_else(|| format!("--set expects control=value, got `{kv}`"))?;
|
||||
let v: f64 = v.trim().parse().map_err(|_| format!("--set {k}: `{v}` is not a number"))?;
|
||||
// `inf` / `NaN` parse as f64 but become JSON null, which the control would silently ignore.
|
||||
let v: f64 =
|
||||
v.trim().parse().ok().filter(|n: &f64| n.is_finite()).ok_or_else(|| format!("--set {k}: `{v}` is not a finite number"))?;
|
||||
values.insert(k.trim().to_string(), json!(v));
|
||||
}
|
||||
"--settings" => settings = Some(read_settings(take_value(args, &mut i, "--settings")?)?),
|
||||
|
||||
Reference in New Issue
Block a user