[Asterisk-code-review] res sorcery realtime: Remove leading ^ requirement. (asterisk[master])

Mark Michelson asteriskteam at digium.com
Tue Jan 12 10:41:52 CST 2016


Mark Michelson has uploaded a new change for review.

  https://gerrit.asterisk.org/1992

Change subject: res_sorcery_realtime: Remove leading ^ requirement.
......................................................................

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
---
M res/res_sorcery_realtime.c
1 file changed, 1 insertion(+), 5 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/92/1992/1

diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c
index 8807c01..716263b 100644
--- a/res/res_sorcery_realtime.c
+++ b/res/res_sorcery_realtime.c
@@ -222,12 +222,8 @@
 	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 + 1);
 
 	if (!(fields = ast_variable_new(field, value, ""))) {
 		return;

-- 
To view, visit https://gerrit.asterisk.org/1992
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I22b4dc5d7f3f11bb29ac2e42ef94682e9bab3b20
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list