diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 40408523d..87364f620 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -28,6 +28,7 @@ New features:: Bug fixes:: + * core: do not remove quotes in arguments of command /eval as they can be part of the evaluated expression/condition (issue #1601) * core: display an error when the buffer is not found with command /command -buffer * exec: fix search of command by identifier * irc: fix completion of commands /halfop and /dehalfop diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 0d9648990..d538bfd9f 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -2023,7 +2023,7 @@ COMMAND_CALLBACK(debug) COMMAND_CALLBACK(eval) { int i, print_only, split_command, condition, debug, error; - char *result, *ptr_args, *expr, **commands; + char *result, *ptr_args, **commands; const char **debug_output; struct t_hashtable *pointers, *options; @@ -2103,36 +2103,31 @@ COMMAND_CALLBACK(eval) if (print_only) { - expr = string_remove_quotes (ptr_args, "\""); - if (expr) + result = eval_expression (ptr_args, pointers, NULL, options); + gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args); + if (result) { - result = eval_expression (expr, pointers, NULL, options); - gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args); - if (result) - { - gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - result, - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - free (result); - } - else - { - gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>", - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), - GUI_COLOR(GUI_COLOR_CHAT), - _("error"), - GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); - } - free (expr); - if (options && debug) - { - debug_output = hashtable_get (options, - "debug_output"); - if (debug_output) - gui_chat_printf (NULL, "%s", debug_output); - } + gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]", + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + result, + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + free (result); + } + else + { + gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>", + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS), + GUI_COLOR(GUI_COLOR_CHAT), + _("error"), + GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS)); + } + if (options && debug) + { + debug_output = hashtable_get (options, + "debug_output"); + if (debug_output) + gui_chat_printf (NULL, "%s", debug_output); } } else diff --git a/tests/unit/core/test-core-eval.cpp b/tests/unit/core/test-core-eval.cpp index 5e5f9762b..ca28dccc2 100644 --- a/tests/unit/core/test-core-eval.cpp +++ b/tests/unit/core/test-core-eval.cpp @@ -203,6 +203,8 @@ TEST(CoreEval, EvalCondition) WEE_CHECK_EVAL("1", "-0xA3 < 2"); WEE_CHECK_EVAL("1", "1 == 18 > 5"); WEE_CHECK_EVAL("1", "abc == abc"); + WEE_CHECK_EVAL("1", "'abc' == 'abc'"); + WEE_CHECK_EVAL("1", "\"abc\" == \"abc\""); WEE_CHECK_EVAL("1", "(26 > 5)"); WEE_CHECK_EVAL("1", "((26 > 5))"); WEE_CHECK_EVAL("1", "(5 < 26)");