[Home]

Summary:ASTERISK-13991: New function to escape any character in a string
Reporter:agjohnson (agjohnson)Labels:
Date Opened:2009-04-20 15:46:36Date Closed:2011-06-07 14:00:48
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Functions/func_strings
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) escape.txt
Description:I was having issues with ODBC functions in Asterisk.  Asterisk was interperating a comma as a delimiter, even if it was contained in a variable that I was passing as a value to the function.  This may be correct, but I needed a function to escape commas inside of variables I was passing to an ODBC function.

The new function's name is ESCAPE(<escape-chars>|<string>).  It will escape every instance of the characters specified inside of the given string.

I am not a C programmer and I apologize for not uploading this as a diff against trunk.
Comments:By: agjohnson (agjohnson) 2009-04-20 15:48:08

I included:

res |= ast_custom_function_unregister(&escape_function);

res |= ast_custom_function_register(&escape_function);

though I'm not sure I needed to.

By: Tilghman Lesher (tilghman) 2009-04-20 15:54:08

Why not just quote the argument?

By: agjohnson (agjohnson) 2009-04-20 17:02:13

Quoting the argument does not work (at least not in 1.4).  I tried quotes, escaped quotes, single quotes, and escaped single quotes.  I originally wrote this patch a against 1.4.

By: agjohnson (agjohnson) 2009-04-20 17:24:37

I verified that ODBC functions work differently in 1.6 than 1.4.  Escaping commas is no longer necessary in 1.6 if you wrap it in quotes.

This function might still be usefull, but is not needed in 1.6 for the specific thing I was trying to accomplish.

By: Tilghman Lesher (tilghman) 2009-04-20 19:37:06

Simpler workaround possible in 1.6.