diff options
author | Mark Michelson <mmichelson@digium.com> | 2016-02-02 10:52:29 -0600 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2016-02-02 15:01:37 -0600 |
commit | 65223618717be8c6db93e324e2273b1dd79eb182 (patch) | |
tree | 16bdac00c0b27b5e618a9b4f7e911846c6b67739 /res | |
parent | c9a5f98ef431f73cca05206be12f63d80c69f925 (diff) |
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
Diffstat (limited to 'res')
-rw-r--r-- | res/res_sorcery_realtime.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/res/res_sorcery_realtime.c b/res/res_sorcery_realtime.c index 1a30e0c59..83736a102 100644 --- a/res/res_sorcery_realtime.c +++ b/res/res_sorcery_realtime.c @@ -223,7 +223,11 @@ static void sorcery_realtime_retrieve_regex(const struct ast_sorcery *sorcery, v /* 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; |