]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix parse err in originate code
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Jul 2010 19:21:44 +0000 (14:21 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Jul 2010 19:21:44 +0000 (14:21 -0500)
src/include/switch_utils.h
src/switch_event.c
src/switch_ivr_originate.c

index 7c4541671e2db1177aaec58d054189dc270f8c4f..514f78d0d89d545907be248e4fbb8c9e66812718 100644 (file)
@@ -92,6 +92,47 @@ static inline switch_bool_t switch_is_moh(const char *s)
        return SWITCH_TRUE;
 }
 
+/* find a character (find) in a string (in) and return a pointer to that point in the string where the character was found 
+   using the array (allowed) as allowed non-matching characters, when (allowed) is NULL, behaviour should be identical to strchr()
+ */
+static inline char *switch_strchr_strict(const char *in, char find, const char *allowed)
+{
+       const char *p;
+
+       switch_assert(in);
+
+       p = in;
+
+       while(p && *p) {
+               const char *a = allowed;
+               int found = 0;
+
+               if (!a) {
+                       found = 1;
+               } else {
+
+                       while(a && *a) {
+
+                               if (*p == *a) {
+                                       found = 1;
+                                       break;
+                               }
+                       
+                               a++;
+                       }
+
+               }
+               
+               if (!found) return NULL;
+
+               if (*p == find) break;
+
+               p++;
+       }
+
+       return (char *) p;
+}
+
 #define switch_arraylen(_a) (sizeof(_a) / sizeof(_a[0]))
 #define switch_split(_data, _delim, _array) switch_separate_string(_data, _delim, _array, switch_arraylen(_array))
 
index 130032c0edbcbd7c0eaa95887b6801523af5578a..ed2b38466a5ebda990330dca7af6b3dc421ef7c1 100644 (file)
@@ -1064,7 +1064,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
        
        check_a = end;
        
-       while (check_a && (check_b = strchr(check_a, a))) {
+       while (check_a && (check_b = switch_strchr_strict(check_a, a, " "))) {
                if ((check_b = switch_find_end_paren(check_b, a, b))) {
                        check_a = check_b;
                }
@@ -1090,7 +1090,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
                        char *pnext;
                        *next++ = '\0';
 
-                       if ((pnext = strchr(next, a))) {
+                       if ((pnext = switch_strchr_strict(next, a, " "))) {
                                next = pnext + 1;
                        }
                }
index 1edc491be5df23efe7e277a2ba87669a4b45ac5b..9cd71f334e3635ccac4fb5e94681be00063ee08c 100644 (file)
@@ -2313,7 +2313,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                }
 
                                if (p == end) {
-                                       end = strchr(p, '[');
+                                       end = switch_strchr_strict(p, '[', " ");
                                }
 
                                p++;
@@ -2537,7 +2537,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                current_variable = NULL;
                                switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false");
 
-
+                               printf("ASS %s\n", vdata);
                                if (vdata) {
                                        char *var_array[1024] = { 0 };
                                        int var_count = 0;
@@ -2552,7 +2552,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                                        char *pnext;
                                                        *next++ = '\0';
 
-                                                       if ((pnext = strchr(next, '['))) {
+                                                       if ((pnext = switch_strchr_strict(next, '[', " "))) {
                                                                next = pnext + 1;
                                                        }
                                                }