[Asterisk-code-review] res sorcery realtime: Fix regex regression. (asterisk[13.7])
Joshua Colp
asteriskteam at digium.com
Fri Feb 5 09:40:49 CST 2016
Joshua Colp has uploaded a new change for review.
https://gerrit.asterisk.org/2207
Change subject: res_sorcery_realtime: Fix regex regression.
......................................................................
res_sorcery_realtime: Fix regex regression.
A regression was introduced where searching for realtime PJSIP objects
by regex by starting the regex with a leading "^" would cause no items
to be returned.
This was due to a change which attempted to drop the requirement for a
leading "^" to be present due to how some CLI commands formulate their
regexes. However, the change, rather than simply eliminating the
requirement, caused any regexes that did begin with "^" to end up not
returning the expected results.
This change fixes the problem by inspecting the regex and formulating
the realtime query differently depending on if it begins with "^".
ASTERISK-25702 #close
Reported by Nic Colledge
Patches:
realtime_retrieve_regex.patch submitted by Alexei Gradinari License #5691
Change-Id: I055df608a6e6a10732044fa737a9fe8dca602693
(cherry picked from commit 32fc784284b570a05841d95c6d9a373b4bf3a35d)
---
M res/res_sorcery_realtime.c
1 file changed, 5 insertions(+), 1 deletion(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/07/2207/1
diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c
index eb790e5..b16069b 100644
--- a/res/res_sorcery_realtime.c
+++ b/res/res_sorcery_realtime.c
@@ -223,7 +223,11 @@
/* The realtime API provides no direct ability to do regex so for now we support a limited subset using pattern matching */
snprintf(field, sizeof(field), "%s LIKE", UUID_FIELD);
- snprintf(value, sizeof(value), "%%%s%%", regex);
+ if (regex[0] == '^') {
+ snprintf(value, sizeof(value), "%s%%", regex + 1);
+ } else {
+ snprintf(value, sizeof(value), "%%%s%%", regex);
+ }
if (!(fields = ast_variable_new(field, value, ""))) {
return;
--
To view, visit https://gerrit.asterisk.org/2207
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I055df608a6e6a10732044fa737a9fe8dca602693
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13.7
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
More information about the asterisk-code-review
mailing list