Merge PR #3006: CLI-HOSTILE: render --set refuses inf / NaN instead of dropping the value

This commit is contained in:
aiongg
2026-10-31 02:06:53 +00:00
2 changed files with 9 additions and 1 deletions
+3 -1
View File
@@ -685,7 +685,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")?)?),
+6
View File
@@ -184,6 +184,12 @@ fn render_subcommand() {
let o = Command::new(binary()).args(["render", input.to_str().unwrap(), "-o", out.to_str().unwrap(), "--set", "nope=1"]).output().unwrap();
assert!(!o.status.success());
assert!(String::from_utf8_lossy(&o.stderr).contains("unknown control"));
// Values that parse as f64 but are not finite fail cleanly too.
for bad in ["light.exposure=inf", "light.exposure=-inf", "light.exposure=NaN", "light.exposure=1e999"] {
let o = Command::new(BIN).args(["render", input.to_str().unwrap(), "-o", out.to_str().unwrap(), "--set", bad]).output().unwrap();
assert!(!o.status.success(), "{bad} must be refused");
assert!(String::from_utf8_lossy(&o.stderr).contains("not a finite number"), "{bad}");
}
}
/// Issue #1730: `render --settings` took a `.lcpreset` from `preset.export`, ignored its wrapper