]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip_messaging: Update To URI only if it is a SIP(S) URI
authorMaximilian Fridrich <m.fridrich@commend.com>
Thu, 7 May 2026 06:53:28 +0000 (08:53 +0200)
committergithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 12 May 2026 16:27:48 +0000 (16:27 +0000)
When a message is sent via ARI, the ARI endpoint only provides a To
field which is also used as destination field. This means that the To
field might not necessarily contain a SIP URI but might instead specify
an Asterisk endpoint (in MessageDestinationInfo format). This led to
many warnings even though the message was sent correctly.

The fix is to only call `ast_sip_update_to_uri` if the To field starts
with the sip: or sips: scheme.

Resolves: #1357

res/res_pjsip_messaging.c

index 929779a0f183aafc0c271ed517c6c69318feb678..ddcc8bb945e80e99235fd11dd4d1465d2033b45f 100644 (file)
@@ -959,7 +959,15 @@ static int msg_send(void *data)
                if (ast_begins_with(msg_to, "pjsip:")) {
                        msg_to += 6;
                }
-               ast_sip_update_to_uri(tdata, msg_to);
+               /*
+                * Only attempt to update the To URI if it's actually a SIP/SIPS URI.
+                * When sending via ARI, the To field is also used as destination
+                * (MessageDestinationInfo) and therefore might not contain a SIP URI.
+                * ast_sip_create_request still sets the correct To header.
+                */
+               if (ast_begins_with(msg_to, "sip:") || ast_begins_with(msg_to, "sips:")) {
+                       ast_sip_update_to_uri(tdata, msg_to);
+               }
        } else {
                /*
                 * If there was no To in the message, it's still possible