httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject svn commit: r560612 - in /httpd/mod_mbox/trunk/module-2.0: mod_mbox.h mod_mbox_mime.c mod_mbox_out.c
Date Sat, 28 Jul 2007 21:07:48 GMT
Author: jerenkrantz
Date: Sat Jul 28 14:07:47 2007
New Revision: 560612

URL: http://svn.apache.org/viewvc?view=rev&rev=560612
Log:
Fix up base64 binary decoding - such as seen with:

http://mail-archives.apache.org/mod_mbox/ws-axis-user/200704.mbox/raw/%3C460FD722.7050303@wso2.com%3E/2

* module-2.0/mod_mbox.h
  (mbox_mime_decode_body): Optionally return decomposed length.
* module-2.0/mod_mbox_mime.c
  (mbox_mime_decode_body): Optionally return decomposed length.
  (mbox_mime_get_body): Pass NULL as we're assuming text.
* module-2.0/mod_mbox_out.c
  (mbox_raw_message): Pass NULL for text/* MIME decoding; use ap_rwrite for
  potentially binary encoded attachments and such.

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

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox.h
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox.h?view=diff&rev=560612&r1=560611&r2=560612
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox.h (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox.h Sat Jul 28 14:07:47 2007
@@ -130,7 +130,7 @@
 mbox_mime_message_t *mbox_mime_decode_multipart(apr_pool_t *p, char *body,
 						char *ct, mbox_cte_e cte,
 						char *boundary);
-char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, apr_size_t len);
+char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, apr_size_t len, apr_size_t
*ret_len);
 char *mbox_mime_get_body(apr_pool_t *p, mbox_mime_message_t *m);
 void mbox_mime_display_static_structure(request_rec *r, mbox_mime_message_t *m,
 					char *link);

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c?view=diff&rev=560612&r1=560611&r2=560612
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_mime.c Sat Jul 28 14:07:47 2007
@@ -290,7 +290,8 @@
 }
 
 /* Decode a MIME part body, according to its CTE. */
-char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body, apr_size_t len)
+char *mbox_mime_decode_body(apr_pool_t *p, mbox_cte_e cte, char *body,
+                            apr_size_t len, apr_size_t *ret_len)
 {
     char *new_body;
 
@@ -304,9 +305,13 @@
 
     if (cte == CTE_BASE64) {
         len = mbox_cte_decode_b64(new_body);
+        if (ret_len)
+            *ret_len = len;
     }
     else if (cte == CTE_QP) {
-	len = mbox_cte_decode_qp(new_body);
+        len = mbox_cte_decode_qp(new_body);
+        if (ret_len)
+            *ret_len = len;
     }
 
     new_body[len] = 0;
@@ -330,7 +335,7 @@
     if (strncasecmp(m->content_type, "text/", strlen("text/")) == 0) {
         char *new_body;
 
-	new_body = mbox_mime_decode_body(p, m->cte, m->body, m->body_len);
+	new_body = mbox_mime_decode_body(p, m->cte, m->body, m->body_len, NULL);
 	if (!new_body) {
 	    return MBOX_FETCH_ERROR_STR;
 	}

Modified: httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c?view=diff&rev=560612&r1=560611&r2=560612
==============================================================================
--- httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c (original)
+++ httpd/mod_mbox/trunk/module-2.0/mod_mbox_out.c Sat Jul 28 14:07:47 2007
@@ -981,9 +981,9 @@
         apr_size_t len = m->body_end - m->body_start;
 
         ap_set_content_type(r, "text/plain");
-	ap_rprintf(r, "%s", mbox_mime_decode_body(r->pool, m->cte,
-						  m->raw_body, len));
-	return OK;
+        ap_rprintf(r, "%s", mbox_mime_decode_body(r->pool, m->cte,
+                                                  m->raw_body, len, NULL));
+        return OK;
     }
 
     /* First, parse the MIME structure, and look for the correct
@@ -1029,14 +1029,17 @@
 
     if (mime_part->body_len > 0) {
         const char* pdata;
-        /* XXXX: Not binary data safe? */
+        apr_size_t ret_len;
+
         mime_part->body[mime_part->body_len] = 0;
+
         pdata = mbox_mime_decode_body(r->pool,
                                       mime_part->cte,
                                       mime_part->body,
-                                      mime_part->body_len);
-        if (pdata != NULL) {
-            ap_rputs(pdata, r);
+                                      mime_part->body_len,
+                                      &ret_len);
+        if (pdata != NULL && ret_len) {
+            ap_rwrite(pdata, ret_len, r);
         }
     }
 



Mime
View raw message