Parse arguments node for match criteria, always returning an array. Match criteria are always comma-separated and should be arrays.
(arg_node: tree_sitter::Node, input: &str, input_bytes: &[u8], _keyword_info: &KeywordInfo)
| 336 | /// Parse arguments node for match criteria, always returning an array. |
| 337 | /// Match criteria are always comma-separated and should be arrays. |
| 338 | fn parse_arguments_node_as_array(arg_node: tree_sitter::Node, input: &str, input_bytes: &[u8], _keyword_info: &KeywordInfo) -> Result<Value, SshdConfigError> { |
| 339 | let mut cursor = arg_node.walk(); |
| 340 | let mut vec: Vec<Value> = Vec::new(); |
| 341 | |
| 342 | let children: Vec<_> = arg_node.named_children(&mut cursor).collect(); |
| 343 | |
| 344 | for node in &children { |
| 345 | if node.is_error() { |
| 346 | return Err(SshdConfigError::ParserError(t!("parser.failedToParseNode", input = input).to_string())); |
| 347 | } |
| 348 | let arg = node.utf8_text(input_bytes)?; |
| 349 | match node.kind() { |
| 350 | "boolean" => { |
| 351 | let arg_str = arg.trim(); |
| 352 | vec.push(Value::Bool(arg_str.eq_ignore_ascii_case("yes"))); |
| 353 | } |
| 354 | "string" => { |
| 355 | let arg_str = arg.trim(); |
| 356 | // Unescape backslashes (sshd -T escapes them on Windows) |
| 357 | let unescaped = unescape_backslashes(arg_str); |
| 358 | vec.push(Value::String(unescaped)); |
| 359 | }, |
| 360 | "number" => { |
| 361 | vec.push(Value::Number(arg.parse::<u64>()?.into())); |
| 362 | }, |
| 363 | _ => return Err(SshdConfigError::ParserError(t!("parser.unknownNode", kind = node.kind()).to_string())) |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | // Always return array for match criteria |
| 368 | Ok(Value::Array(vec)) |
| 369 | } |
| 370 | |
| 371 | /// Parse `sshd_config` to map. |
| 372 | /// |
no test coverage detected