httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s.@apache.org
Subject svn commit: r1325875 - /httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c
Date Fri, 13 Apr 2012 17:56:04 GMT
Author: sf
Date: Fri Apr 13 17:56:03 2012
New Revision: 1325875

URL: http://svn.apache.org/viewvc?rev=1325875&view=rev
Log:
Fix buf in RFC2047 decoding with Q encoding if the string started with
'='

Modified:
    httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c

Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c?rev=1325875&r1=1325874&r2=1325875&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mod_mbox_cte.c Fri Apr 13 17:56:03
2012
@@ -298,6 +298,9 @@ out:
  *
  * These strings complies to the following syntax :
  * =?charset?mode?data?= rest
+ *
+ * Appends decoded string to vb, resturns
+ * position where to continue parsing.
  */
 static char *mbox_cte_decode_rfc2047(apr_pool_t *p, char *src, struct ap_varbuf *vb)
 {
@@ -312,24 +315,22 @@ static char *mbox_cte_decode_rfc2047(apr
 
     /* Encoding mode (first '?' after charset) */
     mode = strstr(charset, "?");
-    if (!mode || mode == src) {
+    if (!mode) {
         return src;
     }
     mode++;
 
     /* Fetch data */
     data = strstr(mode, "?");
-    if (!data || data != mode + 1) {
+    if (!data || data != mode + 1)
         return src;
-    }
     data++;
 
     /* Look for the end bound */
     rest = strstr(data, "?=");
-    if (!rest) {
+    if (!rest)
         return src;
-    }
-    *rest = '\0';
+    data = apr_pstrmemdup(p, data, rest - data);
 
     /* Quoted-Printable decoding : mode 'q' */
     if ((*mode == 'q') || (*mode == 'Q')) {
@@ -351,8 +352,6 @@ static char *mbox_cte_decode_rfc2047(apr
         data_len = mbox_cte_decode_b64(data);
     }
     else {
-        /* XXX we may have modified data above */
-        *rest = '?';
         return src;
     }
 
@@ -376,7 +375,7 @@ static char *mbox_cte_decode_rfc2047(apr
 /* MIME header decoding (see RFC 2047). */
 char *mbox_cte_decode_header(apr_pool_t *p, char *src)
 {
-    char *start, *end = NULL, *cont;
+    char *start, *cont;
     struct ap_varbuf vb;
     int seen_encoded_word = 0;
     if (src == NULL || *src == '\0')
@@ -386,9 +385,7 @@ char *mbox_cte_decode_header(apr_pool_t 
 
     do {
         start = strstr(src, "=?");
-        if (start)
-            end = strstr(start, "?=");
-        if (!start || !end) {
+        if (!start) {
             if (vb.strlen == 0)
                 return src;
             return apr_pstrcat(p, vb.buf, src, NULL);
@@ -412,10 +409,9 @@ char *mbox_cte_decode_header(apr_pool_t 
 
         cont = mbox_cte_decode_rfc2047(p, start, &vb);
         if (cont == start) {
-            /* decoding failed, copy original string */
-            end += 2;
-            ap_varbuf_strmemcat(&vb, start, end - start);
-            src = end;
+            /* decoding failed, copy start delimiter and continue */
+            ap_varbuf_strmemcat(&vb, start, 2);
+            src = start + 2;
         }
         else {
             src = cont;



Mime
View raw message