[sr-dev] git:master:a98d06fc: Merge pull request #1730 from ycaner06/patch-11

GitHub noreply at github.com
Mon Nov 19 12:57:30 CET 2018


Module: kamailio
Branch: master
Commit: a98d06fcd32a0f9aa48ccb12e9056fa84f9d739e
URL: https://github.com/kamailio/kamailio/commit/a98d06fcd32a0f9aa48ccb12e9056fa84f9d739e

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: GitHub <noreply at github.com>
Date: 2018-11-19T12:57:26+01:00

Merge pull request #1730 from ycaner06/patch-11

textops: fixed get_body_part function for non-multipart contents error

---

Modified: src/core/msg_translator.c
Modified: src/modules/textops/textops.c

---

Diff:  https://github.com/kamailio/kamailio/commit/a98d06fcd32a0f9aa48ccb12e9056fa84f9d739e.diff
Patch: https://github.com/kamailio/kamailio/commit/a98d06fcd32a0f9aa48ccb12e9056fa84f9d739e.patch

---

diff --git a/src/core/msg_translator.c b/src/core/msg_translator.c
index 83cdd134ca..a272aeb6bc 100644
--- a/src/core/msg_translator.c
+++ b/src/core/msg_translator.c
@@ -1713,7 +1713,7 @@ int get_boundary(struct sip_msg* msg, str* boundary)
 		msg->content_type->body.len);
 	if (params.s == NULL)
 	{
-		LM_INFO("Content-Type hdr has no params <%.*s>\n",
+		LM_INFO("Content-Type hdr has no boundary params <%.*s>\n",
 				msg->content_type->body.len, msg->content_type->body.s);
 		return -1;
 	}
diff --git a/src/modules/textops/textops.c b/src/modules/textops/textops.c
index 40827baeae..ff784642e5 100644
--- a/src/modules/textops/textops.c
+++ b/src/modules/textops/textops.c
@@ -2761,7 +2761,7 @@ static int ki_remove_multibody(sip_msg_t* msg, str* content_type)
 	}
 
 	if(get_boundary(msg, &boundary)!=0) {
-		LM_ERR("Cannot get boundary. Is body multipart?\n");
+		LM_ERR("Cannot get boundary from Content type header. Is body multipart?\n");
 		return -1;
 	}
 
@@ -2851,18 +2851,23 @@ static int ki_get_body_part_helper(sip_msg_t* msg, str* ctype, pv_spec_t *dst,
 
 	body.s = get_body(msg);
 	if (body.s == 0) {
-		LM_ERR("failed to get the message body\n");
+		LM_ERR("failed to get the content message body\n");
 		return -1;
 	}
 	body.len = msg->len - (int)(body.s - msg->buf);
 	if (body.len == 0) {
-		LM_DBG("message body has zero length\n");
+		LM_DBG("Content body has zero length\n");
 		return -1;
 	}
 
 	if(get_boundary(msg, &boundary)!=0) {
-		LM_ERR("Cannot get boundary. Is body multipart?\n");
-		return -1;
+		LM_DBG("Content is not multipart so return all content body as string\n");
+		memset(&val, 0, sizeof(pv_value_t));
+		val.flags = PV_VAL_STR;
+		val.rs.s = body.s;
+		val.rs.len =body.len;
+		dst->setf(msg, &dst->pvp, (int)EQ_T, &val);
+		return 1;
 	}
 
 	start = body.s;
@@ -2968,7 +2973,7 @@ static int get_body_part_helper(sip_msg_t* msg, char* ctype, char* ovar, int mod
 	str content_type;
 
 	if(ctype==0) {
-		LM_ERR("invalid parameters\n");
+		LM_ERR("invalid Content-type parameters\n");
 		return -1;
 	}
 
@@ -3680,7 +3685,7 @@ int ki_in_list_prefix(sip_msg_t* _m, str* subject, str* list, str* vsep)
 {
 	int sep;
 	char *at, *past, *next_sep, *s;
-	
+
 	if(subject==NULL || subject->len<=0 || list==NULL || list->len<=0
 			|| vsep==NULL || vsep->len<=0)
 		return -1;




More information about the sr-dev mailing list