[Asterisk-code-review] res pjsip messaging: Allow application/* for in-dialog MESS... (asterisk[13])

Jenkins2 asteriskteam at digium.com
Thu Jun 28 06:02:38 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/9292 )

Change subject: res_pjsip_messaging:  Allow application/* for in-dialog MESSAGEs
......................................................................

res_pjsip_messaging:  Allow application/* for in-dialog MESSAGEs

In addition to text/* content types, incoming_in_dialog_request now
accepts application/* content types.

Also fixed a length issue when copying the body text.  It was one
character short.

ASTERISK-27942

Change-Id: I4e54d8cc6158dc47eb8fdd6ba0108c6fd53f2818
---
M main/channel.c
M res/res_pjsip_messaging.c
2 files changed, 13 insertions(+), 10 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Benjamin Keith Ford: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/main/channel.c b/main/channel.c
index 49f3be7..fe24695 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4930,8 +4930,8 @@
 		ast_debug(1, "Sending TEXT to %s: %s\n", ast_channel_name(chan), body);
 		res = ast_channel_tech(chan)->send_text(chan, body);
 	} else {
-		ast_debug(1, "Channel technology does not support sending text on channel '%s'\n",
-			ast_channel_name(chan));
+		ast_debug(1, "Channel technology does not support sending content type '%s' on channel '%s'\n",
+			S_OR(content_type, "text/plain"), ast_channel_name(chan));
 		res = -1;
 	}
 	ast_clear_flag(ast_channel_flags(chan), AST_FLAG_BLOCKING);
diff --git a/res/res_pjsip_messaging.c b/res/res_pjsip_messaging.c
index cbc6ea5..c6ea1dc 100644
--- a/res/res_pjsip_messaging.c
+++ b/res/res_pjsip_messaging.c
@@ -80,22 +80,25 @@
  * \internal
  * \brief Checks to make sure the request has the correct content type.
  *
- * \details This module supports the following media types: "text/\*".
+ * \details This module supports the following media types: "text/\*", "application/\*".
  * Return unsupported otherwise.
  *
  * \param rdata The SIP request
  */
-static enum pjsip_status_code check_content_type_any_text(const pjsip_rx_data *rdata)
+static enum pjsip_status_code check_content_type_in_dialog(const pjsip_rx_data *rdata)
 {
 	int res = PJSIP_SC_UNSUPPORTED_MEDIA_TYPE;
-	pj_str_t text = { "text", 4};
+	static const pj_str_t text = { "text", 4};
+	static const pj_str_t application = { "application", 11};
 
-	/* We'll accept any text/ content type */
+	/* We'll accept any text/ or application/ content type */
 	if (rdata->msg_info.msg->body && rdata->msg_info.msg->body->len
-		&& pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0) {
+		&& (pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &text) == 0
+			|| pj_stricmp(&rdata->msg_info.msg->body->content_type.type, &application) == 0)) {
 		res = PJSIP_SC_OK;
 	} else if (rdata->msg_info.ctype
-		&& pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0) {
+		&& (pj_stricmp(&rdata->msg_info.ctype->media.type, &text) == 0
+		|| pj_stricmp(&rdata->msg_info.ctype->media.type, &application) == 0)) {
 		res = PJSIP_SC_OK;
 	}
 
@@ -800,7 +803,7 @@
 		return 0;
 	}
 
-	code = check_content_type_any_text(rdata);
+	code = check_content_type_in_dialog(rdata);
 	if (code != PJSIP_SC_OK) {
 		send_response(rdata, code, dlg, tsx);
 		return 0;
@@ -849,7 +852,7 @@
 		send_response(rdata, PJSIP_SC_INTERNAL_SERVER_ERROR, dlg, tsx);
 		return 0;
 	}
-	ast_copy_string(attrs[pos].value, rdata->msg_info.msg->body->data, rdata->msg_info.msg->body->len);
+	ast_copy_string(attrs[pos].value, rdata->msg_info.msg->body->data, rdata->msg_info.msg->body->len + 1);
 	pos++;
 
 	msg = ast_msg_data_alloc(AST_MSG_DATA_SOURCE_TYPE_IN_DIALOG, attrs, pos);

-- 
To view, visit https://gerrit.asterisk.org/9292
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I4e54d8cc6158dc47eb8fdd6ba0108c6fd53f2818
Gerrit-Change-Number: 9292
Gerrit-PatchSet: 4
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180628/31d00a0b/attachment.html>


More information about the asterisk-code-review mailing list