mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-23 20:36:21 +00:00
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:
@@ -342,6 +342,20 @@ parse_args_with_freetext__returns__quoted_freetext(void** state)
|
||||
g_strfreev(args);
|
||||
}
|
||||
|
||||
void
|
||||
parse_args_with_freetext__returns__quoted_start_of_freetext(void** state)
|
||||
{
|
||||
char* inp = "/cmd arg1 \"arg2 with space\" more text";
|
||||
gboolean result = FALSE;
|
||||
gchar** args = parse_args_with_freetext(inp, 1, 2, &result);
|
||||
|
||||
assert_true(result);
|
||||
assert_int_equal(2, g_strv_length(args));
|
||||
assert_string_equal("arg1", args[0]);
|
||||
assert_string_equal("\"arg2 with space\" more text", args[1]);
|
||||
g_strfreev(args);
|
||||
}
|
||||
|
||||
void
|
||||
parse_args_with_freetext__returns__third_arg_quoted(void** state)
|
||||
{
|
||||
@@ -504,6 +518,15 @@ count_tokens__handles__escapes(void** state)
|
||||
assert_int_equal(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
count_tokens__handles__multiple_spaces(void** state)
|
||||
{
|
||||
char* inp = "one two";
|
||||
int result = count_tokens(inp);
|
||||
|
||||
assert_int_equal(2, result);
|
||||
}
|
||||
|
||||
void
|
||||
get_start__returns__first_of_one(void** state)
|
||||
{
|
||||
@@ -574,6 +597,16 @@ get_start__handles__escapes(void** state)
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
get_start__handles__multiple_spaces(void** state)
|
||||
{
|
||||
char* inp = "one two";
|
||||
char* result = get_start(inp, 2);
|
||||
|
||||
assert_string_equal("one ", result);
|
||||
g_free(result);
|
||||
}
|
||||
|
||||
void
|
||||
parse_options__returns__empty_hashmap_when_none(void** state)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user