[reSIProcate-users] Why is '%2F' being un-escaped?
Hi,
I have this piece of code:
std::string requestUri("sip:test%2Ftest@xxxxxxxxxx:5060");
resip::NameAddr targetUri;
targetUri = resip::NameAddr(requestUri.c_str());
::sprintf(stderr, "targetUri: \"%s\"",
targetUri.uri().toString().c_str());
When I execute it, I found that the output is
"sip:test/test@xxxxxxxxxx:5060". I am surprised that it automatically
decode "%2F" and convert it to '/'.
I investigated the code resip/stack/Uri.cxx, it is because of these few
lines of code in Uri::parse():
if (!pb.eof())
{
pb.reset(start);
start = pb.position();
pb.skipToOneOf(":@");
#ifdef HANDLE_CHARACTER_ESCAPING
pb.dataUnescaped(mUser, start);
#else
pb.data(mUser, start);
#endif
As I understand from RFC2396 section 3.2.2, '/' is not one of the
allowed characters in the userinfo component, so why does the resip code
un-escape "%2F" to '/' but does not escape it back?
Thank you very much for your time.
Regards,
Kok Meng, Wong