Skip to content

Commit

Permalink
contact: escape Contact header SIP URI
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilianfridrich committed Apr 13, 2023
1 parent 4968456 commit 9506e95
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/sip/contact.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ void sip_contact_set(struct sip_contact *contact, const char *uri,
*/
int sip_contact_print(struct re_printf *pf, const struct sip_contact *contact)
{
char uri[256];
if (!contact)
return 0;

if (contact->uri && strchr(contact->uri, ':'))
return re_hprintf(pf, "Contact: <%s>\r\n", contact->uri);
else
return re_hprintf(pf, "Contact: <sip:%s@%J%s>\r\n",
contact->uri,
contact->addr,
sip_transp_param(contact->tp));
if (contact->uri && strchr(contact->uri, ':')) {
return re_hprintf(pf, "Contact: <%H>\r\n", uri_escape, contact->uri);
}
else {
re_snprintf(uri, sizeof(uri), "sip:%s@%J%s",
contact->uri,
contact->addr,
sip_transp_param(contact->tp));
return re_hprintf(pf, "Contact: <%H>\r\n", uri_escape, uri);
}
}

0 comments on commit 9506e95

Please sign in to comment.