Skip to main content

Stripping spaces from critical input fields

Posted by axisinternet on Sun, 02/08/2009

Ran into a problem that had me going for a bit. We had a couple of tenants that could not make calls from their phones. Asterisk was sending the calls to our OpenSIPS SIP router as it should be then OpenSIPS was rejecting the message with an error about an bad From header. Turned up the debugging in my OpenSIPS config and found that the From SIP URI had a space - e.g.:


sip:1115551212 @asterisk.domain.tld

Note the space before the @ sign. Checked the Default Caller ID Number in their tenant setup and, sure enough, there was a trailing space on the phone number there. Removed that, saved the tenant, and problem was resolved.

So, it'd be great if you could make sure on such fields where spaces in the data are not valid, that PBX Mgr strips leading and tailing spaces from the input.


Submitted by eeman on Sun, 02/08/2009 Permalink

I see this all the time. People think that the callerid= field is supposed to be

callerid=Jane Doe <5555551212>

but in reality its supposed to be callerid=Jane Doe<5555551212>

I just cleaned up something similar on a tenant someone else at work created; I found trailing spaces. I am not sure if he put them there or if the 'create sip extension' process inserted the space.

I'm glad to hear that you were able to troubleshoot the problem.

Submitted by eeman on Sun, 02/08/2009 Permalink

I also wanted to comment that this would not mark the first time a lack of adherence resulted in other-side work-arounds. Take SIPROXD for example. Did you know that in order to get Alert-Info headers to pass through SIPROXD you have to change the useragent= field in sip.conf to something OTHER than 'asterisk'? Why? Because freepbx and all the other countless poor examples of using Alert-Info on phones such as Polycom phones do not adhere to the RFC structure.

poor example: SipAddHeader(Alert-Info: Ring Answer)

correct syntax: SipAddHeader(Alert-Info: <Ring Answer>)

The RFC3261 clearly calls for LAQUOT and RAQUOT (the < > symbols) nestled around the alert-param. Siproxd was build around libosip which would reject the improperly formatted header. throwing out the INVITE. So MANY, in the wrong, complained that Siproxd wouldn't work with PBX Manager, that Siproxd now has code that if the useragent is 'asterisk', the Alert-Info header is removed entirely before passing along. In order for my correctly formatted headers to reach the phones, I have to change my useragent= setting in sip.conf.