fix: ensure consistent unescaping and space handling

Unescape any character following a backslash. This fixes autocompletion
for names with escaped spaces.
For example: `/msg Thor\ Odinson hello`

Signed-off-by: Michael Vetter <jubalh@iodoru.org>
This commit is contained in:
Michael Vetter
2026-03-30 18:33:59 +02:00
parent bda5b0f844
commit df1f1e5ef1
8 changed files with 92 additions and 2 deletions

View File

@@ -345,3 +345,31 @@ autocomplete_complete__returns__regular_ascii(void** state)
autocomplete_free(ac);
free(result);
}
void
autocomplete_complete__handles__escaped_spaces(void** state)
{
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Thor Odinson");
char* result = autocomplete_complete(ac, "Thor\\ ", TRUE, FALSE);
assert_string_equal("\"Thor Odinson\"", result);
autocomplete_free(ac);
free(result);
}
void
autocomplete_complete__handles__escaped_quotes(void** state)
{
Autocomplete ac = autocomplete_new();
autocomplete_add(ac, "Thor \"The Thunderer\" Odinson");
char* result = autocomplete_complete(ac, "Thor \\\"", TRUE, FALSE);
assert_string_equal("\"Thor \\\"The Thunderer\\\" Odinson\"", result);
autocomplete_free(ac);
free(result);
}