Pjsip callerid= specification -- syntax?

Hi – what are the permitted characters in the callerid= line in a pjsip.conf extension definition?

I see examples like

callerid=Bob Smith <1234>

…but I can’t seem to find the permitted characters. For example, it seems like “;” is not possible in callerid because it will start a comment? Any others? Quotation marks, apostrophes, special characters, unicode, etc?

Any way to escape the ; character?

Thanks.

The escape character in Asterisk .conf files is backslash.

It will also be necessary to conform to the restrictions in SIP itself. I believe you will need to URL encode anything that is special to SIP, and may find that the other end does not decode it.

I’m not sure how double quote, which is significant to SIP, is handled. Semicolon is a parameter delimiter in SIP, and will, at least in the name part, need protecting. I’m not sure if that is with double quotes, or with URL encoding. See RFC 3261 for details.

If the actual ID is gatewayed to ISDN, you will be restricted to telephone digits.

There may be other restrictions.

Thank you. Looks like we’re talking about the From: header in the SIP exchange, which for the quoted-string variant of the display-name just comes down to escaping \ and “ with a \. (I.e. doesn’t look to my ignorant eyes like URL encoding will be needed.) The other allowable characters are defined by the qdtext grammar:

qdtext = LWS / %x21 / %x23-5B / %x5D-7E / UTF8-NONASCII

…that is, spaces, tabs, all standard ASCII chars (except \ and “ unless quoted with \), and UTF8 characters. So AFAIK you could have:

callerid=Blah Blah `'~!{}@#$%^&*()™ <123-456-7890>

For escaping something, I guess I need to escape that once for asterisk.conf and then again for SIP?, but I guess I can test; e.g.:

callerid=Blah \\\\ \; Blah \\” Blah \\”

…perhaps get sent over SIP as: From: “Blah \\ ; Blah \” Blah \”” <sips:…

(And of course as you say the other end may or may not handle the full spec, so probably best to err on the side of simpler callerid= values.)

For some reason these RFCs never seem to specify max header length either (noticed this a lot in my email industry days) so everyone seems to have a different notion of that.

Nope – asterisk takes care of escaping things for SIP. Only thing needed was for the semicolon: \; gets sent as ; as expected.

Even sending a backslash doesn’t need escaping, so “\\” in pjsip.conf just gets sent as “\\” over SIP. Seems the preprocessor in asterisk is pretty basic: just search/replace \; with ; it would seem.

All the other characters worked as expected.

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