Browse Source

nathelper(k): skip trailing whitespaces and crlf

- was affecting multipart bodies, causing nortpproxy string to be placed
  in the wrong position
- reported by Pascal Maugeri
Daniel-Constantin Mierla 16 years ago
parent
commit
caef5ace20
1 changed files with 18 additions and 15 deletions
  1. 18 15
      modules_k/nathelper/nhelpr_funcs.c

+ 18 - 15
modules_k/nathelper/nhelpr_funcs.c

@@ -206,21 +206,9 @@ int extract_body(struct sip_msg *msg, str *body )
 		goto error;
 		goto error;
 	}
 	}
 
 
-	for (skip = 0; skip < body->len; skip++) {
-		c = body->s[body->len - skip - 1];
-		if (c != '\r' && c != '\n')
-			break;
-	}
-	if (skip == body->len) {
-		LM_ERR("empty body");
-		goto error;
-	}
-	body->len -= skip;
-
-	/*LM_DBG("DEBUG:extract_body:=|%.*s|\n",body->len,body->s);*/
-
 	if(ret!=2)
 	if(ret!=2)
-		return 1;
+		goto done;
+
 	/* multipart body */
 	/* multipart body */
 	if(get_mixed_part_delimiter(&msg->content_type->body,&mpdel) < 0) {
 	if(get_mixed_part_delimiter(&msg->content_type->body,&mpdel) < 0) {
 		goto error;
 		goto error;
@@ -266,12 +254,27 @@ int extract_body(struct sip_msg *msg, str *body )
 		{
 		{
 			body->s = rest;
 			body->s = rest;
 			body->len = p2-rest;
 			body->len = p2-rest;
-			return 1;
+			goto done;
 		}
 		}
 	}
 	}
 
 
 error:
 error:
 	return -1;
 	return -1;
+
+done:
+	for (skip = 0; skip < body->len; skip++) {
+		c = body->s[body->len - skip - 1];
+		if (c != '\r' && c != '\n')
+			break;
+	}
+	if (skip == body->len) {
+		LM_ERR("empty body");
+		goto error;
+	}
+	body->len -= skip;
+
+	/*LM_DBG("DEBUG:extract_body:=|%.*s|\n",body->len,body->s);*/
+	return 1;
 }
 }
 
 
 /*
 /*