From 4cd58c3b20e04e1acd3d77c964dc1dd9a7b85d74 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Tue, 12 Jan 2016 10:36:15 -0600 Subject: res_sorcery_realtime: Remove leading ^ requirement. res_sorcery_realtime's search-by-regex callback performed a check to ensure that the passed-in regex began with a caret (^). If it did not, then no results would be returned. This callback only started to become used when "like" support was added to PJSIP CLI commands. The CLI command for listing objects would pass an empty regex ("") to the sorcery backend if no "like" statement was present. For most sorcery backends, this resulted in returning all objects. However, for realtime, this resulted in returning no objects. This commit seeks to fix the regression by removing the requirement from res_sorcery_realtime for the passed-in-regex to begin with a caret. ASTERISK-25689 #close Reported by Marcelo Terres Change-Id: I22b4dc5d7f3f11bb29ac2e42ef94682e9bab3b20 --- tests/test_sorcery_realtime.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'tests/test_sorcery_realtime.c') diff --git a/tests/test_sorcery_realtime.c b/tests/test_sorcery_realtime.c index 3791c7c8d..eaee9ffbf 100644 --- a/tests/test_sorcery_realtime.c +++ b/tests/test_sorcery_realtime.c @@ -67,17 +67,13 @@ static int realtime_is_object_matching(const char *object_id, const struct ast_v /* If we are doing a pattern matching we need to remove the LIKE from the name */ if ((like = strstr(name, " LIKE"))) { - char *pattern, *field_value = ast_strdupa(field->value); + char *field_value = ast_strdupa(field->value); *like = '\0'; value = ast_strdupa(ast_variable_retrieve(realtime_objects, object_id, name)); - if (!(pattern = strchr(field_value, '%'))) { - return 0; - } - - *pattern = '\0'; + field_value = ast_strip_quoted(field_value, "%", "%"); if (strncmp(value, field_value, strlen(field_value))) { return 0; @@ -567,7 +563,7 @@ AST_TEST_DEFINE(object_retrieve_regex) return AST_TEST_FAIL; } - if (!(objects = ast_sorcery_retrieve_by_regex(sorcery, "test", "^blah-"))) { + if (!(objects = ast_sorcery_retrieve_by_regex(sorcery, "test", "blah-"))) { ast_test_status_update(test, "Failed to retrieve a container of objects\n"); return AST_TEST_FAIL; } else if (ao2_container_count(objects) != 2) { -- cgit v1.2.3