httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From max...@apache.org
Subject svn commit: r411176 - /httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c
Date Fri, 02 Jun 2006 15:06:30 GMT
Author: maxime
Date: Fri Jun  2 08:06:29 2006
New Revision: 411176

URL: http://svn.apache.org/viewvc?rev=411176&view=rev
Log:
 * Apply patch from Gareth McCaughan on MIME part-names parsing.
 * Fix a bug in multipart messages boundary parsing : boundaries may
   not be double quoted (for example Apple Mail does not quote them).


Modified:
    httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c

Modified: httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c?rev=411176&r1=411175&r2=411176&view=diff
==============================================================================
--- httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c (original)
+++ httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c Fri Jun  2 08:06:29 2006
@@ -90,11 +90,22 @@
         /* If available, get MIME part name */
         tmp = ap_strstr(body, "name=");
         if (tmp && tmp < headers_bound) {
+            int in_quoted = 0;
+            int escaped = 0;
+
             tmp += sizeof("name=") - 1;
             k = tmp;
 
             while (*k) {
-                if (isspace(*k) || *k == ';') {
+                if (in_quoted) {
+                    in_quoted = escaped || (*k != '"');
+                    escaped = (!escaped) && (*k == '\\');
+                }
+                else if (*k == '"') {
+                    in_quoted = 1;
+                    escaped = 0;
+                }
+                else if (isspace(*k) || *k == ';') {
                     eol = *k;
                     *k = 0;
                     break;
@@ -191,16 +202,27 @@
 
         /* If the boundary was not given, we must look for it in the headers */
         if (!boundary) {
-            tmp = ap_strstr(body, "boundary=\"");
+            int quoted = 0;
+            char c;
+
+            tmp = ap_strstr(body, "boundary=");
             if (!tmp) {
                 return NULL;
             }
 
-            tmp += sizeof("boundary=\"") - 1;
+            tmp += sizeof("boundary=") - 1;
             k = tmp;
 
+            if (*k == '"') {
+                quoted = 1;
+                k++;
+                tmp++;
+            }
+
             while (*k) {
-                if (*k == '"') {
+                if ((quoted && *k == '"') ||
+                    (!quoted && (isspace(*k) || *k == ';'))) {
+                    c = *k;
                     *k = 0;
                     break;
                 }
@@ -208,7 +230,7 @@
             }
 
             mail->boundary = apr_pstrdup(p, tmp);
-            *k = '"';
+            *k = c;
         }
 
         /* Otherwise, the boundary is as given to us */



Mime
View raw message