'@' is not an allowed character in URI parameter values so I see no PJSIP bug here. IMO you need to have the UA that sends these URIs fixed. If it is not possible, you could try escaping the @ characters (replace them with %40 instead of _) before passing the URIs to the parser - thus you don't lose the information.
Cheers,
Zoltan
PS. From https://tools.ietf.org/html/rfc3261#section-25.1
uri-parameter = transport-param / user-param / method-param
/ ttl-param / maddr-param / lr-param / other-param
other-param = pname [ "=" pvalue ]
pvalue = 1*paramchar
paramchar = param-unreserved / unreserved / escaped
param-unreserved = "[" / "]" / "/" / ":" / "&" / "+" / "$"
unreserved = alphanum / mark
mark = "-" / "_" / "." / "!" / "~" / "*" / "'"
/ "(" / ")"
escaped = "%" HEXDIG HEXDIG
Von: Brian White <mscdex@xxxxxxxxxx>
An: pjsip@xxxxxxxxxxxxxxx
Datum: 07.04.2017 01:53
Betreff: [Newsletter] pjsip_parse_uri() fails with '@' in URI parameter
Gesendet von: "pjsip" <pjsip-bounces@xxxxxxxxxxxxxxx>
Hello,
We're running into problems with pjsip being unable to parse a SIP URI with a '@' character in URI parameters.
FWIW reproduction code (tested with 2.5.5 and 2.6):
#include <pjsip.h>
int main(int argc, char** argv) {
if (argc < 2) {
fprintf(stderr, "Missing URI\n");
return 1;
}
pj_init();
pj_caching_pool cp;
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
pj_pool_t* pool = pj_pool_create(
&cp.factory, // pool factory
"test", // pool name
4096, // init size
512, // increment size
NULL // callback on error
);
pjsip_endpoint* endpt;
pjsip_endpt_create(&cp.factory, "test", &endpt);
char* uri = argv[1];
printf("Trying to parse (%d): %s\n", strlen(uri), uri);
pjsip_uri* parsed_uri = pjsip_parse_uri(pool, uri, strlen(uri), PJSIP_PARSE_URI_AS_NAMEADDR);
if (parsed_uri)
printf("success\n");
else
printf("failure\n");
return 0;
}
A call to this program like this will print 'success': ./pjsip-bug '<sip:123@192.168.1.1>'
A call to this program like this will print 'failure': ./pjsip-bug '<sip:123@192.168.1.1;foo;bar=baz@quux>'
Currently our workaround consists of replacing all '@' characters with '_' just so that we can actually parse the URI, because (fortunately) we currently do not utilize the parameters in which these characters tend to occur in. However, we would like a better (more relaxed parsing) solution from pjsip in case other restricted characters are sent in URI parameters. Is such a (feasible) solution already possible?_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org