Return-Path: X-Original-To: apmail-httpd-cvs-archive@www.apache.org Delivered-To: apmail-httpd-cvs-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D0FFC90AA for ; Thu, 26 Apr 2012 20:34:56 +0000 (UTC) Received: (qmail 69955 invoked by uid 500); 26 Apr 2012 20:34:56 -0000 Delivered-To: apmail-httpd-cvs-archive@httpd.apache.org Received: (qmail 69897 invoked by uid 500); 26 Apr 2012 20:34:56 -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 69889 invoked by uid 99); 26 Apr 2012 20:34:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Apr 2012 20:34:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Apr 2012 20:34:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 625FA23889BB; Thu, 26 Apr 2012 20:34:32 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1331072 - in /httpd/mod_mbox/trunk: CHANGES module-2.0/mbox_parse.c Date: Thu, 26 Apr 2012 20:34:32 -0000 To: cvs@httpd.apache.org From: sf@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120426203432.625FA23889BB@eris.apache.org> Author: sf Date: Thu Apr 26 20:34:31 2012 New Revision: 1331072 URL: http://svn.apache.org/viewvc?rev=1331072&view=rev Log: Try to obtain the list post address from the file .listname if no List-Post header is found. PR: 53120 Submitted by: Daniel Shahaf, Stefan Fritsch Modified: httpd/mod_mbox/trunk/CHANGES httpd/mod_mbox/trunk/module-2.0/mbox_parse.c Modified: httpd/mod_mbox/trunk/CHANGES URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/CHANGES?rev=1331072&r1=1331071&r2=1331072&view=diff ============================================================================== --- httpd/mod_mbox/trunk/CHANGES (original) +++ httpd/mod_mbox/trunk/CHANGES Thu Apr 26 20:34:31 2012 @@ -1,5 +1,8 @@ Changes for mod_mbox 0.2 + *) Try to obtain the list post address from the file .listname if no + List-Post header is found. PR 53120. [Daniel Shahaf, Stefan Fritsch] + *) Convert mails and From and Subject headers to UTF-8. Re-indexing of all mbox files is necessary. The minimum required httpd version is now 2.3.15. PR 48864. PR 52182. PR 52195. Modified: httpd/mod_mbox/trunk/module-2.0/mbox_parse.c URL: http://svn.apache.org/viewvc/httpd/mod_mbox/trunk/module-2.0/mbox_parse.c?rev=1331072&r1=1331071&r2=1331072&view=diff ============================================================================== --- httpd/mod_mbox/trunk/module-2.0/mbox_parse.c (original) +++ httpd/mod_mbox/trunk/module-2.0/mbox_parse.c Thu Apr 26 20:34:31 2012 @@ -42,6 +42,9 @@ #include "apr_date.h" #include "apr_lib.h" +/* for dirname() */ +#include + #define OPEN_DBM(r, db, flags, suffix, temp, status) \ temp = apr_pstrcat(r->pool, r->filename, suffix, NULL); \ status = apr_dbm_open(&db, temp, flags, APR_OS_DEFAULT, r->pool ); @@ -1120,14 +1123,41 @@ static apr_table_t *fetch_first_headers( return table; } -char *mbox_get_list_post(request_rec *r, char *path) +/* Creates fake List-Post header from file generated by: + * printf '%s@%s\n' > PATH/.listname + */ +static char *read_listname(char *path, apr_pool_t *p) { apr_status_t rv; - char *fullpath; apr_file_t *f; - apr_table_t *headers; + char buf[256]; + apr_size_t nread; + + rv = apr_file_open(&f, + apr_pstrcat(p, path, "/.listname", (char*)NULL), + APR_READ, APR_OS_DEFAULT, p); + if (rv != APR_SUCCESS) { + return NULL; + } + + rv = apr_file_read_full(f, buf, sizeof(buf) - 1, &nread); + if (rv != APR_EOF) { + return NULL; + } + + buf[nread] = '\0'; + if (nread > 0 && buf[--nread] == '\n') { + buf[nread] = '\0'; + } + apr_file_close(f); + return apr_pstrcat(p, "", NULL); +} - fullpath = apr_pstrcat(r->pool, r->filename, path, NULL); +static const char *get_list_post(request_rec *r, char *path, char *fullpath) +{ + apr_status_t rv; + apr_file_t *f; + apr_table_t *headers; rv = apr_file_open(&f, fullpath, APR_READ, APR_OS_DEFAULT, r->pool); @@ -1136,13 +1166,23 @@ char *mbox_get_list_post(request_rec *r, } headers = fetch_first_headers(r, f); + apr_file_close(f); + if (headers == NULL) { return NULL; } - apr_file_close(f); + return apr_table_get(headers, "List-Post"); +} + +char *mbox_get_list_post(request_rec *r, char *path) +{ + char *fullpath = apr_pstrcat(r->pool, r->filename, path, NULL); + const char *list_post = get_list_post(r, path, fullpath); - return apr_pstrdup(r->pool, apr_table_get(headers, "List-Post")); + if (list_post != NULL) + return apr_pstrdup(r->pool, list_post); + return read_listname(dirname(fullpath), r->pool); } /**