[asterisk-dev] Filter() function broken ?

Pavel Troller patrol at sinus.cz
Tue Feb 9 13:04:47 CST 2010


Hi!
  I was experimenting with the Filter() function to filter some characters
from the dial string and it behaves strangely. I've created the following
filter as a part of my Dial() command:

${FILTER("A-Za-z0-9_+\-",${fnum})}

One of characters I wanted to pass is the "-" one, so I prepended it with
a backlash, as stated in the Filter() function help text.
However, it looks that I triggered a bug. I was surprised, that by supplying
the dialstring "0042133333&DAHDI/g1/2212", the slashes were not filtered out,
even this character was not between the allowed ones.
To find a problem, I've made a debug, and the surprise is here:

[Feb  9 19:50:11] DEBUG[21285] func_strings.c: c1=65, c2=90
[Feb  9 19:50:11] DEBUG[21285] func_strings.c: c1=97, c2=122
[Feb  9 19:50:11] DEBUG[21285] func_strings.c: c1=48, c2=57
[Feb  9 19:50:11] DEBUG[21285] func_strings.c: c1=43, c2=-1
[Feb  9 19:50:11] DEBUG[21285] func_strings.c: Allowed: ABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyzz01234567899_+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~^?~@~A~B~C~D~E~F~G~H~I~J~K~L~M~N~O~P~Q~R~S~T~U~V~W~X~Y~Z~[~\~]~^~_| Ą
[Feb  9 19:50:11] DEBUG[21285] pbx.c: Function result is '0042133333DAHDI/g1/2212'

It looks that the backslash before the - is not properly recognized, and that
a missing upper limit after the - causes that the filter is filled up with all
possible characters following, in our case, "+". Is it a bug, or I just
improperly understood the help text ? BTW, I was testing it with quotes (as
shown here) as well as without them and there is no difference.

With regards, Pavel

P.S. Asterisk-1.6.1.14.



More information about the asterisk-dev mailing list