diff --git a/grammars/tree-sitter-ssh-server-config/grammar.js b/grammars/tree-sitter-ssh-server-config/grammar.js index 9722a5f64..ce34d1286 100644 --- a/grammars/tree-sitter-ssh-server-config/grammar.js +++ b/grammars/tree-sitter-ssh-server-config/grammar.js @@ -34,7 +34,7 @@ module.exports = grammar({ repeat1(choice($.comment, $.keyword)), ), - arguments: $ => repeat1(choice($.boolean, $.number, $._quotedString, $._commaSeparatedString)), + arguments: $ => repeat1(choice($.boolean, $.number, $.quotedString, $._commaSeparatedString)), alphanumeric: $ => /[a-zA-Z0-9]+/i, boolean: $ => choice('yes', 'no'), @@ -43,7 +43,7 @@ module.exports = grammar({ string: $ => /[^\r\n,"]+/, _commaSeparatedString: $ => seq($.string, repeat(seq(',', $.string))), - _quotedString: $ => seq('\"', $.string, '\"'), + quotedString: $ => seq('\"', $.string, '\"'), } }); diff --git a/grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt b/grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt index b8842d877..061c6a481 100644 --- a/grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt +++ b/grammars/tree-sitter-ssh-server-config/test/corpus/valid_expressions.txt @@ -9,7 +9,8 @@ authorizedKEYSfile "path to authorized keys file" (keyword (alphanumeric) (arguments - (string)))) + (quotedString + (string))))) ===== comment ===== @@ -36,7 +37,8 @@ authorizedkeysfile "path to authorized keys file" (keyword (alphanumeric) (arguments - (string))))) + (quotedString + (string)))))) ===== boolean and match ===== @@ -59,7 +61,8 @@ authorizedkeysfile "path to authorized keys file" (keyword (alphanumeric) (arguments - (string))))) + (quotedString + (string)))))) ===== directive with = operator ===== @@ -108,7 +111,8 @@ AllowGroups group1 "group two" (alphanumeric) (arguments (string) - (string)))) + (quotedString + (string))))) ===== directive with comma-separated arguments ===== @@ -316,7 +320,8 @@ passwordauthentication yes (alphanumeric) (arguments (string) - (string)))) + (quotedString + (string))))) (match (keyword (alphanumeric) @@ -367,4 +372,5 @@ allowgroups administrators "openssh users" (alphanumeric) (arguments (string) - (string)))) \ No newline at end of file + (quotedString + (string))))) \ No newline at end of file diff --git a/resources/sshdconfig/src/parser.rs b/resources/sshdconfig/src/parser.rs index 53447ced1..716c6629b 100644 --- a/resources/sshdconfig/src/parser.rs +++ b/resources/sshdconfig/src/parser.rs @@ -155,7 +155,7 @@ fn parse_arguments_node(arg_node: tree_sitter::Node, input: &str, input_bytes: & return Err(SshdConfigError::ParserError(t!("parser.failedToParseChildNode", input = input).to_string())); } let argument: Value = match node.kind() { - "boolean" | "string" => { + "boolean" | "string" | "quotedString" => { let Ok(arg) = node.utf8_text(input_bytes) else { return Err(SshdConfigError::ParserError( t!("parser.failedToParseNode", input = input).to_string() @@ -176,7 +176,7 @@ fn parse_arguments_node(arg_node: tree_sitter::Node, input: &str, input_bytes: & return Err(SshdConfigError::ParserError( t!("parser.invalidValue").to_string() )); - } + }, _ => return Err(SshdConfigError::ParserError(t!("parser.unknownNode", kind = node.kind()).to_string())) }; if is_vec { @@ -242,7 +242,7 @@ mod tests { let result: Map = parse_text_to_map(input).unwrap(); let expected = vec![ Value::String("administrators".to_string()), - Value::String("openssh users".to_string()), + Value::String("\"openssh users\"".to_string()), ]; assert_eq!(result.get("allowgroups").unwrap(), &Value::Array(expected)); }