diff options
| author | Illia <[email protected]> | 2017-01-15 20:00:21 +0300 |
|---|---|---|
| committer | Illia <[email protected]> | 2017-01-15 20:00:21 +0300 |
| commit | 6d2b5df1ee3cfdf638b403d1c8a27990aca839d1 (patch) | |
| tree | 7fd4e53a3e78446c118558d7ac05d4cc56dd41ef /src/utils | |
| parent | Add shard latency tracking (diff) | |
| download | serenity-6d2b5df1ee3cfdf638b403d1c8a27990aca839d1.tar.xz serenity-6d2b5df1ee3cfdf638b403d1c8a27990aca839d1.zip | |
allow quotes to be escaped in quote parser
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/mod.rs | 6 |
1 files changed, 5 insertions, 1 deletions
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<P: AsRef<Path>>(path: P) -> Result<String> { pub fn parse_quotes(s: &str) -> Vec<String> { 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<String> { in_string = false; } else { current_str.push(x); + escaping = false; } } else if x == ' ' { if !current_str.is_empty() { |