From 6d2b5df1ee3cfdf638b403d1c8a27990aca839d1 Mon Sep 17 00:00:00 2001 From: Illia Date: Sun, 15 Jan 2017 20:00:21 +0300 Subject: allow quotes to be escaped in quote parser --- src/utils/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/utils') diff --git a/src/utils/mod.rs b/src/utils/mod.rs index f0e4d3a..ca20b57 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -204,11 +204,14 @@ pub fn read_image>(path: P) -> Result { pub fn parse_quotes(s: &str) -> Vec { let mut args = vec![]; let mut in_string = false; + let mut escaping = false; let mut current_str = String::default(); for x in s.chars() { if in_string { - if x == '"' { + if x == '\\' && !escaping { + escaping = true; + } else if x == '"' && !escaping { if !current_str.is_empty() { args.push(current_str); } @@ -217,6 +220,7 @@ pub fn parse_quotes(s: &str) -> Vec { in_string = false; } else { current_str.push(x); + escaping = false; } } else if x == ' ' { if !current_str.is_empty() { -- cgit v1.2.3