From 9050b05ff76811eefe93f3a0271ddb3fa33d7d8d Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Mon, 10 Sep 2018 11:16:27 -0400 Subject: [PATCH] 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 <philippe.gorley@savoirfairelinux.com> --- src/ringdht/ringaccount.cpp | 11 +++++------ src/sip/sipaccount.cpp | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp index e8af3b5a01..4ec86f97eb 100644 --- a/src/ringdht/ringaccount.cpp +++ b/src/ringdht/ringaccount.cpp @@ -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_; diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 2c8e2d8166..fbb52c2a4d 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -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() ? "" : "@"), -- GitLab