summaryrefslogtreecommitdiff
path: root/res/res_sorcery_realtime.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-01-12 10:36:15 -0600
committerMark Michelson <mmichelson@digium.com>2016-01-12 13:04:49 -0600
commit4cd58c3b20e04e1acd3d77c964dc1dd9a7b85d74 (patch)
treea857cd1516dcec20fb45246d38ae778827d8f94c /res/res_sorcery_realtime.c
parentace79fadad4c551c7d5185011c0e9e208b60175e (diff)
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
Diffstat (limited to 'res/res_sorcery_realtime.c')
-rw-r--r--res/res_sorcery_realtime.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c
index 3412b92cc..eb790e57e 100644
--- a/res/res_sorcery_realtime.c
+++ b/res/res_sorcery_realtime.c
@@ -218,16 +218,12 @@ static void sorcery_realtime_retrieve_multiple(const struct ast_sorcery *sorcery
static void sorcery_realtime_retrieve_regex(const struct ast_sorcery *sorcery, void *data, const char *type, struct ao2_container *objects, const char *regex)
{
- char field[strlen(UUID_FIELD) + 6], value[strlen(regex) + 2];
+ char field[strlen(UUID_FIELD) + 6], value[strlen(regex) + 3];
RAII_VAR(struct ast_variable *, fields, NULL, ast_variables_destroy);
/* The realtime API provides no direct ability to do regex so for now we support a limited subset using pattern matching */
- if (regex[0] != '^') {
- return;
- }
-
snprintf(field, sizeof(field), "%s LIKE", UUID_FIELD);
- snprintf(value, sizeof(value), "%s%%", regex + 1);
+ snprintf(value, sizeof(value), "%%%s%%", regex);
if (!(fields = ast_variable_new(field, value, ""))) {
return;