httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From max...@apache.org
Subject svn commit: r366174 - /httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
Date Thu, 05 Jan 2006 12:49:54 GMT
Author: maxime
Date: Thu Jan  5 04:49:51 2006
New Revision: 366174

URL: http://svn.apache.org/viewcvs?rev=366174&view=rev
Log:
 * module-2.0/mod_mbox_mime.c:
    (mbox_mime_decode_multipart): Handle empty boundaries.


Modified:
    httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
URL: http://svn.apache.org/viewcvs/httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c?rev=366174&r1=366173&r2=366174&view=diff
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c Thu Jan  5 04:49:51 2006
@@ -173,7 +173,7 @@
        and process its sub parts by recursive calls. */
     if (strncmp(mail->content_type, "multipart/", strlen("multipart/")) == 0) {
 	int end = 0, count = 0;
-	char *search, *bound;
+	char *search, *bound, *boundary_line;
 
 	/* If the boundary was not given, we must look for it in the headers */
 	if (!boundary) {
@@ -204,10 +204,15 @@
 
 	/* Now we have our boundary string. We must : look for it once
 	 (begining of MIME part) and then look for the end boundary :
-	 --boundary-- to mark the end of the MIME part */
+	 --boundary-- to mark the end of the MIME part.
+
+	 In order to handle empty boundaries, we'll look for the
+	 boundary plus the \n. */
+
+	boundary_line = apr_pstrcat(p, "--", mail->boundary, "\n", NULL);
 
 	/* The start boundary */
-	bound = ap_strstr(mail->body, mail->boundary);
+	bound = ap_strstr(mail->body, boundary_line);
 	if (!bound) {
 	    return NULL;
 	}
@@ -221,16 +226,15 @@
 	*tmp = 0;
 
 	/* Set the search begining to the line after the start boundary. */
-	search = bound + strlen(mail->boundary) + 1;
+	search = bound + strlen(boundary_line);
 
 	/* While the MIME part is not finished, go through all sub parts */
 	while (!end) {
 	    char *inbound;
 
-	    inbound = ap_strstr(search+strlen(mail->boundary), mail->boundary);
+	    inbound = ap_strstr(search, boundary_line);
 	    if (inbound) {
-		char *t = inbound - 2;
-		*t = 0;
+		*inbound = 0;
 	    }
 
 	    /* Allocate a new pointer for the sub part, and parse it. */
@@ -242,10 +246,9 @@
 	       search begining to the line after this new start
 	       boundary */
 	    if (inbound) {
-		char *t = inbound - 2;
-		*t = '-';
+		*inbound = '-';
 
-		search = inbound + strlen(mail->boundary) + 1;
+		search = inbound + strlen(boundary_line);
 
 		if (mail->sub[count-1] && mail->sub[count-1]->body) {
 		    mail->sub[count-1]->body_len = inbound - mail->sub[count-1]->body - 2;



Mime
View raw message