From ba857cbe684ab7b9ddc60094f6c44fb7f5b06127 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 5 Jan 2022 10:03:44 +0100 Subject: [PATCH] tools::config: error on newlines in string values Signed-off-by: Wolfgang Bumiller --- src/tools/config.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/tools/config.rs b/src/tools/config.rs index 8dedeaa1..f666a8ab 100644 --- a/src/tools/config.rs +++ b/src/tools/config.rs @@ -137,7 +137,12 @@ fn object_to_writer(output: &mut dyn Write, object: &Object) -> Result<(), Error match value { Value::Null => continue, // delete this entry Value::Bool(v) => writeln!(output, "{}: {}", key, v)?, - Value::String(v) => writeln!(output, "{}: {}", key, v)?, + Value::String(v) => { + if v.as_bytes().contains(&b'\n') { + bail!("value for {} contains newlines", key); + } + writeln!(output, "{}: {}", key, v)? + } Value::Number(v) => writeln!(output, "{}: {}", key, v)?, Value::Array(_) => bail!("arrays are not supported in config files"), Value::Object(_) => bail!("complex objects are not supported in config files"),