### Description
I am trying to extract a parameter with transformations from an URI in Kamailio 5.2.3, Centos 7
The problem occurs with uri.param and param.value transformation when the last character of the input string is the separator. I such case an error is thrown and no parameter value can be received. The code should be fixed so that empty parameters are simply skipped.
# Example $var(someuri) = "sip:2660926042@23.26.41.95:65485;app-id=7537263245341023;";
# error with uri.param $var(appid) = $(var(someuri){uri.param,app-id});
# another error with param.value $var(appid) = $(var(someuri){param.value,app-id});
error: "Param name missing after ;"
The problem is here where an error is thrown for zero length params: https://github.com/kamailio/kamailio/blob/master/src/core/parser/parse_param...
if(_s->len == 0) { LM_ERR("Param name missing after %c\n", separator); goto error; }
From where did you get such URI? Because, afaik, by specs/RFC grammar, the uri must not be terminated by `;` -- the last param value must be left without `;`.
I haven't implemented the parser for uri+params, but that's what I understood from the developer long time ago. I know that for some some modparams that use the uri-params parser, I had to check if the last char is `;` and skip it when passing the value to the parser to avoid loosing the checks of the parser to break specs requirements.
The solution right now is to check the last char in such value and skip it using other string transformations such as s.substr.
Hello Daniel,
I receive such URIs from Asterisk 16.3 . This extra delimiter at the end seems to appear when Asterisk has stored contact URIs which are bigger than the db field. My fullcontact field length was 256 bytes in the Asterisk db, now I increased to 512 bytes and the problem went away.
Yes, I chop off the last delimiter in Kamailio now. That prevents the problem.
Thanks for your hints.
Best Gerrit
On 25 Jun 2019, at 18:05, Daniel-Constantin Mierla notifications@github.com wrote:
From where did you get such URI? Because, afaik, by specs/RFC grammar, the uri must not be terminated by ; -- the last param value must be left without ;.
I haven't implemented the parser for uri+params, but that's what I understood from the developer long time ago. I know that for some some modparams that use the uri-params parser, I had to check if the last char is ; and skip it when passing the value to the parser to avoid loosing the checks of the parser to break specs requirements.
The solution right now is to check the last char in such value and skip it using other string transformations such as s.substr.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kamailio/kamailio/issues/1991?email_source=notifications&email_token=ADBOF2RHFJIY2TLEBXBBONDP4IX4NA5CNFSM4H26BGUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYQR3PI#issuecomment-505486781, or mute the thread https://github.com/notifications/unsubscribe-auth/ADBOF2W77WPQLRS437HXUE3P4IX4NANCNFSM4H26BGUA.
I pushed a commit to relax the behaviour of the transformation not to be SIP spec strict in such cases - 1c4af823c39d28b694c1dec607d8d72c5b726456 , hoping to help by being more flexible with values loaded from various sources.
Closed #1991.