You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2012/01/02 19:50:13 UTC
svn commit: r1226510 - in
/httpd/mod_mbox/branches/convert-charsets/module-2.0: mbox_parse.c
mbox_parse.h
Author: sf
Date: Mon Jan 2 18:50:13 2012
New Revision: 1226510
URL: http://svn.apache.org/viewvc?rev=1226510&view=rev
Log:
Parse charset from mail headers and store in dbm
Modified:
httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.c
httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.h
Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.c
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.c?rev=1226510&r1=1226509&r2=1226510&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.c (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.c Mon Jan 2 18:50:13 2012
@@ -59,6 +59,7 @@ typedef struct mb_dbm_data
const char *subject;
const char *references;
const char *content_type;
+ const char *charset;
const char *boundary;
} mb_dbm_data;
@@ -507,6 +508,9 @@ static void normalize_message(request_re
if (!m->content_type || !*m->content_type)
m->content_type = "text/plain";
+ if (m->charset && !*m->charset)
+ m->charset = NULL;
+
apr_time_exp_gmt(&time_exp, m->date);
m->str_date = (char *) apr_pcalloc(r->pool, APR_RFC822_DATE_LEN);
@@ -571,6 +575,7 @@ static apr_status_t fetch_msgc(apr_pool_
fetch_cstring(pool, msgc->subject, msgValue.dptr, pos, tlen);
fetch_cstring(pool, msgc->references, msgValue.dptr, pos, tlen);
fetch_cstring(pool, msgc->content_type, msgValue.dptr, pos, tlen);
+ fetch_cstring(pool, msgc->charset, msgValue.dptr, pos, tlen);
fetch_cstring(pool, msgc->boundary, msgValue.dptr, pos, tlen);
return APR_SUCCESS;
@@ -627,6 +632,7 @@ static apr_status_t store_msgc(apr_pool_
sstrlen(msgc->subject) + sizeof(tlen) +
sstrlen(msgc->references) + sizeof(tlen) +
sstrlen(msgc->content_type) + sizeof(tlen) +
+ sstrlen(msgc->charset) + sizeof(tlen) +
sstrlen(msgc->boundary) + sizeof(tlen);
value = apr_palloc(pool, vlen);
@@ -648,6 +654,7 @@ static apr_status_t store_msgc(apr_pool_
store_cstring(msgc->subject, value, pos, tlen);
store_cstring(msgc->references, value, pos, tlen);
store_cstring(msgc->content_type, value, pos, tlen);
+ store_cstring(msgc->charset, value, pos, tlen);
store_cstring(msgc->boundary, value, pos, tlen);
msgValue.dptr = (char *) value;
@@ -807,11 +814,12 @@ apr_status_t mbox_generate_index(request
temp = apr_table_get(table, "Content-Type");
if (temp) {
- char *p, *boundary, *dup;
+ char *p, *boundary, *dup, *charset;
dup = apr_pstrdup(tpool, temp);
boundary = mbox_strcasestr(dup, "boundary=");
+ charset = mbox_strcasestr(dup, "charset=");
if (boundary) {
- msgc.boundary += sizeof("boundary=") - 1;
+ boundary += strlen("boundary=");
if (boundary[0] == '"') {
++boundary;
if ((p = strstr(boundary, "\""))) {
@@ -824,14 +832,29 @@ apr_status_t mbox_generate_index(request
}
}
}
+ if (charset) {
+ charset += strlen("charset=");
+ if (charset[0] == '"') {
+ ++charset;
+ if ((p = strstr(charset, "\""))) {
+ *p = '\0';
+ }
+ }
+ else {
+ if ((p = strstr(charset, ";"))) {
+ *p = '\0';
+ }
+ }
+ }
msgc.boundary = boundary;
+ msgc.charset = charset;
p = strstr(dup, ";");
if (p) {
*p = '\0';
}
/* Some old clients only sent 'text',
* instead of 'text/plain'. Lets try to be nice to them */
- if (!strcasecmp(msgc.content_type, "text")) {
+ if (!strcasecmp(dup, "text")) {
msgc.content_type = "text/plain";
}
else {
@@ -913,6 +936,7 @@ MBOX_LIST *mbox_load_index(request_rec *
curMsg->from = apr_pstrdup(r->pool, msgc.from);
curMsg->subject = apr_pstrdup(r->pool, msgc.subject);
curMsg->content_type = apr_pstrdup(r->pool, msgc.content_type);
+ curMsg->charset = apr_pstrdup(r->pool, msgc.charset);
curMsg->boundary = apr_pstrdup(r->pool, msgc.boundary);
curMsg->date = msgc.date;
curMsg->raw_ref = apr_pstrdup(r->pool, msgc.references);
@@ -980,6 +1004,7 @@ Message *mbox_fetch_index(request_rec *r
curMsg->from = apr_pstrdup(r->pool, msgc.from);
curMsg->subject = apr_pstrdup(r->pool, msgc.subject);
curMsg->content_type = apr_pstrdup(r->pool, msgc.content_type);
+ curMsg->charset = apr_pstrdup(r->pool, msgc.charset);
curMsg->boundary = apr_pstrdup(r->pool, msgc.boundary);
curMsg->date = msgc.date;
curMsg->raw_ref = apr_pstrdup(r->pool, msgc.references);
Modified: httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.h
URL: http://svn.apache.org/viewvc/httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.h?rev=1226510&r1=1226509&r2=1226510&view=diff
==============================================================================
--- httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.h (original)
+++ httpd/mod_mbox/branches/convert-charsets/module-2.0/mbox_parse.h Mon Jan 2 18:50:13 2012
@@ -118,6 +118,7 @@ typedef struct mbox_mime_message
char *boundary;
char *content_type;
+ char *charset;
char *content_encoding;
char *content_disposition;
char *content_name;
@@ -142,6 +143,7 @@ struct Message_Struct
char *rfc822_date;
char *content_type;
+ char *charset;
char *boundary;
mbox_cte_e cte;