]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3359 --resolve also added %y to printf macros to replace ' with \'
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 7 Jul 2011 20:08:16 +0000 (15:08 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 7 Jul 2011 20:08:23 +0000 (15:08 -0500)
src/mod/languages/mod_lua/mod_lua.cpp
src/switch_mprintf.c
src/switch_utils.c

index ee1e3e2104ab425feaa151c31308c0daf03c362c..dc01aa9fa9d975a73df805cc4eafb7df847e69e5 100644 (file)
@@ -150,9 +150,9 @@ static int lua_parse_and_execute(lua_State * L, char *input_code)
                                switch_stream_handle_t stream = { 0 };
                                SWITCH_STANDARD_STREAM(stream);
 
-                               stream.write_function(&stream, " argv = {[0]='%s', ", input_code);
+                               stream.write_function(&stream, " argv = {[0]='%y', ", input_code);
                                for (x = 0; x < argc; x++) {
-                                       stream.write_function(&stream, "'%s'%s", argv[x], x == argc - 1 ? "" : ", ");
+                                       stream.write_function(&stream, "'%y'%s", argv[x], x == argc - 1 ? "" : ", ");
                                }
                                stream.write_function(&stream, " };");
                                code = (char *) stream.data;
index 595581cbf06a2a421ebd531fd21ef8d47a35bdfe..cdd85088de8ad4dd992672fc205959403f3151c2 100644 (file)
@@ -86,6 +86,7 @@
 #endif
 #define etPOINTER    15                        /* The %p conversion */
 #define etSQLESCAPE3 16
+#define etSQLESCAPE4 17
 
 /*
 ** An "etByte" is an 8-bit unsigned value.
@@ -127,6 +128,7 @@ static const et_info fmtinfo[] = {
        {'q', 0, 4, etSQLESCAPE, 0, 0},
        {'Q', 0, 4, etSQLESCAPE2, 0, 0},
        {'w', 0, 4, etSQLESCAPE3, 0, 0},
+       {'y', 0, 4, etSQLESCAPE4, 0, 0},
        {'c', 0, 0, etCHARX, 0, 0},
        {'o', 8, 0, etRADIX, 0, 2},
        {'u', 10, 0, etRADIX, 0, 0},
@@ -676,6 +678,7 @@ static int vxprintf(void (*func) (void *, const char *, int),       /* Consumer of tex
                        break;
                case etSQLESCAPE:
                case etSQLESCAPE2:
+               case etSQLESCAPE4:
                case etSQLESCAPE3:{
                                int i, j, n, ch, isnull;
                                int needQuote;
@@ -697,12 +700,20 @@ static int vxprintf(void (*func) (void *, const char *, int),     /* Consumer of tex
                                        bufpt = buf;
                                }
                                j = 0;
-                               if (needQuote)
+                               if (needQuote) 
                                        bufpt[j++] = '\'';
                                for (i = 0; (ch = escarg[i]) != 0; i++) {
                                        bufpt[j++] = (char) ch;
-                                       if (ch == '\'' || (xtype == etSQLESCAPE3 && ch == '\\'))
-                                               bufpt[j++] = (char) ch;
+                                       if (xtype == etSQLESCAPE4) {
+                                               if (ch == '\'' || (xtype == etSQLESCAPE3 && ch == '\\')) {
+                                                       bufpt[j] = (char) ch;
+                                                       bufpt[j-1] = (char) '\\';
+                                                       j++;
+                                               }
+                                       } else {
+                                               if (ch == '\'' || (xtype == etSQLESCAPE3 && ch == '\\'))
+                                                       bufpt[j++] = (char) ch;
+                                       }
                                }
                                if (needQuote)
                                        bufpt[j++] = '\'';
index 906a02eba687520b416f4ae99f3428bd56ac0037..221a82335c1c7c4e58b9458716ef7f9776298534 100644 (file)
@@ -1940,11 +1940,11 @@ static unsigned int separate_string_char_delim(char *buf, char delim, char **arr
                }
        }
        /* strip quotes, escaped chars and leading / trailing spaces */
-       if (count > 1) {
-               for (i = 0; i < count; ++i) {
-                       array[i] = cleanup_separated_string(array[i], delim);
-               }
+
+       for (i = 0; i < count; ++i) {
+               array[i] = cleanup_separated_string(array[i], delim);
        }
+
        return count;
 }
 
@@ -2000,11 +2000,11 @@ static unsigned int separate_string_blank_delim(char *buf, char **array, unsigne
                }
        }
        /* strip quotes, escaped chars and leading / trailing spaces */
-       if (count > 1) {
-               for (i = 0; i < count; ++i) {
-                       array[i] = cleanup_separated_string(array[i], 0);
-               }
+
+       for (i = 0; i < count; ++i) {
+               array[i] = cleanup_separated_string(array[i], 0);
        }
+       
        return count;
 }