FreePBX / superfecta

Provides simultaneous use of, and complete control over multiple caller id data sources.
http://www.freepbx.org
GNU General Public License v2.0
56 stars 92 forks source link

Superfecta will not run if incoming CID has non-digit characters #165

Closed lgaetz closed 9 years ago

lgaetz commented 10 years ago

As reported by user @rambo1152, if superfecta is invoked with an incoming CID containing non-digits, it will not run. Log output:

/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta is Answering the Channel
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Scheme is ALL
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The DID passed from Asterisk is: <deleted>
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The number passed from Asterisk is: 1(000) 000-0668
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The CID name passed from Asterisk is: Studio
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Not a valid number

Located on line 36 of /agi/superfecta.agi is this line:

if (!preg_match('/\D/i', $agi->request['agi_callerid'])) {

this check will only permit Superfecta to run if the CID contains digits. For testing purposes I changed it to:

if (true) {

and reran the test with this output:

/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta is Answering the Channel
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Scheme is ALL
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The DID passed from Asterisk is: <deleted>
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The number passed from Asterisk is: 1(000) 000-0668
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: The CID name passed from Asterisk is: Studio
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Executing Scheme..
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Matched CID Rule: '1NXXNXXXXXX' with '10000000668'
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: CID Determined to be: 'Studio'
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Attempting to set lookupcid
/var/www/html/admin/modules/superfecta/agi/superfecta.agi: CID Superfecta: Success!

Success! I can't see any reason to force this check. I will leave in production on a few systems for a few days and report back if any issues.

rambo1152 commented 10 years ago

Wow! I make that about an hour from me raising a ticket to a full fix.

Now if only I could get that sort of service from the developers in my day job...

Patch implemented in my system, and all looks good so far.

Does anyone else get non numerical characters in the CLI?

I am still trying to figure out exactly under what circumstances the hyphen and space are presented. I only see them on my POTS line, and only when the caller is also calling from a POTS line in my city.

lgaetz commented 10 years ago

I have heard of Superfecta failing for this reason before, just recently in fact. The situation was with an incoming POTS line being answered by an Obihai FXO device, and either the POTS line was supplying the CID with non-digit characters, or the Obihai was modifying the CID before passing it to the PBX. The hack was to fix the CID string with a custom context before passing to the from-trunk context.

tm1000 commented 9 years ago

Doesnt seem like this was fixed. Anyways I just changed it to !empty() since there is no reason to run the checks on an empty CID