(command: &str)
| 455 | |
| 456 | #[cfg(windows)] |
| 457 | fn tokenize_windows_command(command: &str) -> Option<Vec<String>> { |
| 458 | let mut tokens = Vec::new(); |
| 459 | let mut current = String::new(); |
| 460 | let mut chars = command.chars().peekable(); |
| 461 | let mut in_single = false; |
| 462 | let mut in_double = false; |
| 463 | |
| 464 | while let Some(ch) = chars.next() { |
| 465 | match ch { |
| 466 | '\'' if !in_double => in_single = !in_single, |
| 467 | '"' if !in_single => in_double = !in_double, |
| 468 | '\\' if in_double => { |
| 469 | if let Some(next) = chars.next() { |
| 470 | current.push(next); |
| 471 | } |
| 472 | } |
| 473 | ch if ch.is_whitespace() && !in_single && !in_double => { |
| 474 | if !current.is_empty() { |
| 475 | tokens.push(std::mem::take(&mut current)); |
| 476 | } |
| 477 | } |
| 478 | other => current.push(other), |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | if in_single || in_double { |
| 483 | return None; |
| 484 | } |
| 485 | |
| 486 | if !current.is_empty() { |
| 487 | tokens.push(current); |
| 488 | } |
| 489 | |
| 490 | Some(tokens) |
| 491 | } |
| 492 | |
| 493 | #[cfg(windows)] |
| 494 | fn parse_simple_windows_http_command(command: &str) -> Option<SimpleWindowsHttpCommand> { |
no test coverage detected