fix(cli): reject --pdf-options that is not a JSON object instead of panicking (#731)

This commit is contained in:
MarekSpodBiedry
2026-10-13 18:42:57 +02:00
parent e862e0a613
commit dfb41f5aea
2 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -261,7 +261,11 @@ fn run(args: &[String]) -> Result<(), String> {
"--page" => page = val()?.parse().map_err(|_| "bad --page")?,
"--scale" => scale = val()?.parse().map_err(|_| "bad --scale")?,
"--pdf-options" => {
pdf_opts = serde_json::from_str(&val()?).map_err(|e| format!("--pdf-options: {e}"))?;
pdf_opts = match serde_json::from_str(&val()?).map_err(|e| format!("--pdf-options: {e}"))? {
Value::Null => json!({}),
o @ Value::Object(_) => o,
_ => return Err("--pdf-options: expected a JSON object".to_string()),
};
}
"--export" => {
let out = val()?;