Index: asterisk-1.2/funcs/func_cdr.c =================================================================== --- asterisk-1.2/funcs/func_cdr.c (revision 42554) +++ asterisk-1.2/funcs/func_cdr.c (working copy) @@ -44,6 +44,7 @@ int argc; char *argv[2]; int recursive = 0; + int mysql_safe = 0; // NEZ struct ast_cdr *cdr = chan->cdr; if (ast_strlen_zero(data)) @@ -60,6 +61,10 @@ argc--; if (strchr(argv[argc], 'r')) recursive = 1; + // NEZ + if (strchr(argv[argc], 'm')) + mysql_safe = 1; + // } /* Find last entry */ @@ -68,6 +73,26 @@ ast_cdr_getvar(cdr, argv[0], &ret, buf, len, recursive); + // NEZ - MySQL safe the string + if (mysql_safe && ret && *ret && len) { + int i1, i2; + char *t = malloc(len+1); + + if (t) { + strncpy(t, ret, len); + for (i1 = 0, i2 = 0; *(t+i1) && i2 < (len-1); i1++) { + if (*(t+i1) == 0x27 || *(t+i1) == 0x5c) { + *(ret+(i2++)) = 0x5c; + } + *(ret+(i2++)) = *(t+i1); + } + *(ret+(i2)) = 0; + + free (t); + } + } + // + return ret; }