Return-Path: Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: (qmail 64311 invoked from network); 2 Jun 2006 15:06:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Jun 2006 15:06:53 -0000 Received: (qmail 40392 invoked by uid 500); 2 Jun 2006 15:06:52 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 40154 invoked by uid 500); 2 Jun 2006 15:06:51 -0000 Mailing-List: contact cvs-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list cvs@httpd.apache.org Received: (qmail 40132 invoked by uid 99); 2 Jun 2006 15:06:51 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jun 2006 08:06:51 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Jun 2006 08:06:50 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 948B11A983A; Fri, 2 Jun 2006 08:06:30 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r411176 - /httpd/mod_mbox/branches/surgery/libmbox/mbox_mime.c Date: Fri, 02 Jun 2006 15:06:30 -0000 To: cvs@httpd.apache.org From: maxime@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060602150630.948B11A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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 */