Commit 9050b05f authored by Andreas Traczyk's avatar Andreas Traczyk

SIP: support colons and chevrons in display names

- fixes crash/lack of connectivity when making calls with a display
  name including colons/chevrons by quoting the display name when
  constructing the SIP contact header for both SIP and Ring
  accounts

Change-Id: I9ba03100fc95316202ab63dea2d28c93f992e432
Reviewed-by: Philippe Gorley's avatarPhilippe Gorley <philippe.gorley@savoirfairelinux.com>
parent 8a16e950
......@@ -2871,23 +2871,22 @@ RingAccount::getToUri(const std::string& to) const
pj_str_t
RingAccount::getContactHeader(pjsip_transport* t)
{
std::string quotedDisplayName = "\"" + displayName_ + "\" " + (displayName_.empty() ? "" : " ");
if (t) {
// FIXME: be sure that given transport is from SipIceTransport
auto tlsTr = reinterpret_cast<tls::SipsIceTransport::TransportData*>(t)->self;
auto address = tlsTr->getLocalAddress().toString(true);
contact_.slen = pj_ansi_snprintf(contact_.ptr, PJSIP_MAX_URL_SIZE,
"%s%s<sips:%s%s%s;transport=dtls>",
displayName_.c_str(),
(displayName_.empty() ? "" : " "),
"%s<sips:%s%s%s;transport=dtls>",
quotedDisplayName.c_str(),
identity_.second->getId().toString().c_str(),
(address.empty() ? "" : "@"),
address.c_str());
} else {
RING_ERR("getContactHeader: no SIP transport provided");
contact_.slen = pj_ansi_snprintf(contact_.ptr, PJSIP_MAX_URL_SIZE,
"%s%s<sips:%s@ring.dht>",
displayName_.c_str(),
(displayName_.empty() ? "" : " "),
"%s<sips:%s@ring.dht>",
quotedDisplayName.c_str(),
identity_.second->getId().toString().c_str());
}
return contact_;
......
......@@ -1461,10 +1461,10 @@ SIPAccount::getContactHeader(pjsip_transport* t)
transport = ";transport=tls";
}
std::string quotedDisplayName = "\"" + displayName_ + "\" " + (displayName_.empty() ? "" : " ");
contact_.slen = pj_ansi_snprintf(contact_.ptr, PJSIP_MAX_URL_SIZE,
"%s%s<%s:%s%s%s:%d%s>",
displayName_.c_str(),
(displayName_.empty() ? "" : " "),
"%s<%s:%s%s%s:%d%s>",
quotedDisplayName.c_str(),
scheme,
username_.c_str(),
(username_.empty() ? "" : "@"),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment