--- res/res_pjsip_refer.c.orig 2020-11-19 13:39:40.000000000 +0100 +++ res/res_pjsip_refer.c 2021-01-24 12:07:07.353611673 +0100 @@ -1059,7 +1059,7 @@ pjsip_generic_string_hdr *refer_to; char *uri; size_t uri_size; - pjsip_uri *target; + pjsip_fromto_hdr *target; pjsip_sip_uri *target_uri; RAII_VAR(struct refer_progress *, progress, NULL, ao2_cleanup); pjsip_param *replaces; @@ -1067,6 +1067,7 @@ static const pj_str_t str_refer_to = { "Refer-To", 8 }; static const pj_str_t str_refer_to_s = { "r", 1 }; + static const pj_str_t str_to = { "To", 2 }; static const pj_str_t str_replaces = { "Replaces", 8 }; if (!session->channel) { @@ -1101,18 +1102,18 @@ uri = ast_alloca(uri_size); ast_copy_pj_str(uri, &refer_to->hvalue, uri_size); - target = pjsip_parse_uri(rdata->tp_info.pool, uri, uri_size - 1, 0); + target = pjsip_parse_hdr(rdata->tp_info.pool, &str_to, uri, uri_size - 1, NULL); if (!target - || (!PJSIP_URI_SCHEME_IS_SIP(target) - && !PJSIP_URI_SCHEME_IS_SIPS(target))) { + || (!PJSIP_URI_SCHEME_IS_SIP(target->uri) + && !PJSIP_URI_SCHEME_IS_SIPS(target->uri))) { pjsip_dlg_respond(session->inv_session->dlg, rdata, 400, NULL, NULL, NULL); ast_debug(3, "Received a REFER without a parseable Refer-To ('%s') on channel '%s' from endpoint '%s'\n", uri, ast_channel_name(session->channel), ast_sorcery_object_get_id(session->endpoint)); return 0; } - target_uri = pjsip_uri_get_uri(target); + target_uri = pjsip_uri_get_uri(target->uri); /* Set up REFER progress subscription if requested/possible */ if (refer_progress_alloc(session, rdata, &progress)) {