浏览代码

topoh: add angle brackets around contact uri

- if there are no angle brackets around initial contact uri, add for
  encoded uri to keep URI parameters properly
Daniel-Constantin Mierla 14 年之前
父节点
当前提交
66f80a68a4
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      modules/topoh/th_msg.c

+ 19 - 0
modules/topoh/th_msg.c

@@ -247,6 +247,7 @@ int th_mask_contact(sip_msg_t *msg)
 	struct lump* l;
 	str out;
 	str in;
+	char *p;
 	contact_t *c;
 
 	if(msg->contact==NULL) 
@@ -270,6 +271,24 @@ int th_mask_contact(sip_msg_t *msg)
 		LM_ERR("cannot encode contact uri\n");
 		return -1;
 	}
+	if(*(in.s-1)!='<')
+	{
+		/* add < > around contact uri if not there */
+		p = (char*)pkg_malloc(out.len+3);
+		if(p==NULL)
+		{
+			LM_ERR("failed to get more pkg\n");
+			pkg_free(out.s);
+			return -1;
+		}
+		*p = '<';
+		strncpy(p+1, out.s, out.len);
+		p[out.len+1] = '>';
+		p[out.len+2] = '\0';
+		pkg_free(out.s);
+		out.s = p;
+		out.len += 2;
+	}
 				
 	l=del_lump(msg, in.s-msg->buf, in.len, 0);
 	if (l==0)