From f51420ba1f29db0fcc0a0f2ffa8a1911c8c5ef3f Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 14 Jan 2020 11:41:48 +0100 Subject: [PATCH] src/section_config.rs: do not allow control characters --- src/section_config.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/section_config.rs b/src/section_config.rs index bfa6b082..854cb282 100644 --- a/src/section_config.rs +++ b/src/section_config.rs @@ -139,9 +139,11 @@ impl SectionConfig { if let Err(err) = parse_simple_value(§ion_id, &self.id_schema) { bail!("syntax error in section identifier: {}", err.to_string()); } + if section_id.chars().any(|c| c.is_control()) { + bail!("detected unexpected control character in section ID."); + } verify_json_object(section_config, &plugin.properties)?; - println!("REAL WRITE {} {} {:?}\n", section_id, type_name, section_config); let head = (self.format_section_header)(type_name, section_id, section_config); @@ -159,6 +161,9 @@ impl SectionConfig { bail!("got unsupported type in section '{}' key '{}'", section_id, key); }, }; + if text.chars().any(|c| c.is_control()) { + bail!("detected unexpected control character in section '{}' key '{}'", section_id, key); + } raw += "\t"; raw += &key; raw += " ";