Filter unwanted characters in dial plan

I’m getting unwanted block element coming through the calls and its causing a lot of headache. So I want to start filtering, can ‘Set Caller ID’ module accomplish this task?

Can I use this function in Set Caller ID module?

Blockquote
${FILTER(0-9a-zA-z,${CALLERID(num)})})
Blockquote
or would I have to put that into extensions_custom.conf?

Thanks,

I’m not sure what your question is, but if you are asking how to block certain caller IDs then it is easiest to use admin > blacklist. I don’t think there can be anything in the callerID other than the characters your filter allows, but to do what i think you are trying to do you would do something like this in extension_custom.conf:

[from-trunk-custom]
exten=>s,1,Set(foo=${FILTER(0-9A-zA-Z,${CallerID(num)})
exten=>s,2,set(${CALLERID(num)}=${foo})

Please note I didn’t check any of that syntax but it should give you the general idea.

To add to that I suggest sending your calls to the [from-trunk-stripped] context, and add

[from-trunk-stripped]
exten => _X!,1,Set(foo=${FILTER(0-9A-zA-Z ,${CALLERIDID(num)})
exten => _X!,n,set(${CALLERID(num)}=${foo})
exten => _X!,n,Goto(from-trunk,${EXTEN},1)

to /etc/asterisk/extensions_custom.conf

My question regards to blocking certain characters in the CallerID, not blocking a certain number. My system is throwing

ERROR[17900][C-000000d4]:json.c:861 ast_json_vpack: Error building JSON from ‘{s: s, s: s}’: Invalid UTF-8 string.

I then found out that the CallerID is including an invalid character, showing as a block element like this : ▒15169877970. So now I want to use Filter function to block out invalid characters and only allow 0-9 a-z A-Z. Can I achieve this in the Caller ID module, or has to be set in the conf file?

Thanks,

The code snipped I gave you should filter ${CALLERID(num)}, ${CALLERID(name)} or put in a line for both.
But dicko’s code is better – put a line for each in his snippet and you should be good.

Jerry - I was given this code to try:

same = n,Set(CALLERID(num)=${FILTER(0-9a-zA-z,${CALLERID(num)})})

I haven’t set a custom dialplan before, this will be first time.
Thoughts?

TTBOMK “same = n,” will break your dialplan. “=” is an assignment operator and I never heard of “same” function. Did you try dicko’s code? The best plan is to start here: https://www.voip-info.org/asterisk-config-extensionsconf

the correct usage of ‘same’ makes it marginally quicker to write dial plans, my previous snippet could be written also

[from-trunk-stripped]
exten => _X!,1,Set(foo=${FILTER(0-9A-zA-Z \-,${CALLERIDID(num)})
     same => n,set(${CALLERID(num)}=${foo})
     same => n,Goto(from-trunk,${EXTEN},1)

(I added a filter for the literal ‘-’ character, note the space between Z and \ that filters space characters also)

I ended up not needing the Filter function since my original issue was resolved by updating to the latest libpri. Thank you everyone.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.