httpd-cvs mailing list archives

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

URL: http://svn.apache.org/viewvc?rev=1325874&view=rev
Log:
mbox_cte_decode_header(): allow NULL strings and handle strings
efficiently where nothing needs to be done

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=1325874&r1=1325873&r2=1325874&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:55:50
2012
@@ -376,20 +376,23 @@ 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, *cont;
+    char *start, *end = NULL, *cont;
     struct ap_varbuf vb;
     int seen_encoded_word = 0;
-    ap_varbuf_init(p, &vb, 100);
+    if (src == NULL || *src == '\0')
+        return "";
+    ap_varbuf_init(p, &vb, 0);
     vb.strlen = 0;
 
     do {
         start = strstr(src, "=?");
-        if (!start)
-            return apr_pstrcat(p, vb.buf, src, NULL);
-
-        end = strstr(start, "?=");
-        if (!end)
+        if (start)
+            end = strstr(start, "?=");
+        if (!start || !end) {
+            if (vb.strlen == 0)
+                return src;
             return apr_pstrcat(p, vb.buf, src, NULL);
+        }
 
         if (start != src) {
             if (seen_encoded_word) {
@@ -399,7 +402,7 @@ char *mbox_cte_decode_header(apr_pool_t 
                     p++;
                 if (p == start)
                     src = start;
-		/* XXX: this is wrong if the next encoded word fails to decode */
+                /* XXX: this is wrong if the next encoded word fails to decode */
             }
             if (start != src) {
                 ap_varbuf_strmemcat(&vb, src, start - src);



Mime
View raw message