this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make argument parsing respect quotes for high level command handler

roufpup c13eff4e 8e9f6fc9

+42 -1
+42 -1
src/high_level/command_handler.rs
··· 114 114 } 115 115 116 116 pub fn split_args(body: &str) -> Vec<&str> { 117 - body.split(" ").collect::<Vec<&str>>() 117 + let mut args: Vec<&str> = Vec::new(); 118 + 119 + let mut quote: bool = false; 120 + let mut last_char: char = ' '; 121 + let body = body.trim(); 122 + let mut start: usize = 0; 123 + 124 + for (i, elem) in body.char_indices() { 125 + if !quote && last_char == '\"' && elem != ' ' { 126 + start = i; 127 + } 128 + 129 + match elem { 130 + ' ' => { 131 + if !quote && last_char != '\"' { 132 + args.push(&body[start..i]); 133 + } 134 + 135 + if !quote { 136 + start = i + 1; 137 + } 138 + } 139 + '\"' => { 140 + if !quote { 141 + start = i + 1; 142 + } else { 143 + args.push(&body[start..i]); 144 + } 145 + 146 + quote = !quote; 147 + } 148 + _ => {} 149 + } 150 + 151 + if i + 1 == body.len() && elem != '\"' { 152 + args.push(&body[start..i + 1]); 153 + } 154 + 155 + last_char = elem; 156 + } 157 + 158 + args 118 159 } 119 160 }