Hi, > Why not make it a configuration option? That way people who want to > obsufucation will get it, and those that don't wont.
A new version of the patch is attached. Add 'MboxAntispam On' to your <LocationMatch ...> section to enable the feature. - Sam -- Maxime Petazzoni (http://www.bulix.org) -- gone crazy, back soon. leave message.
Index: module-2.0/mod_mbox_file.c
===================================================================
--- module-2.0/mod_mbox_file.c (revision 188736)
+++ module-2.0/mod_mbox_file.c (working copy)
@@ -22,18 +22,54 @@
*/
#include "mod_mbox.h"
+#include <string.h>
+/** Antispam protection.
+ *
+ */
+char *email_antispam(char *email)
+{
+ char *pos;
+ int i, p;
+
+ pos = strrchr(email, '@');
+
+ if (!pos) {
+ return email;
+ }
+
+ p = pos - email - 1;
+
+ for (i=0 ; i<3 ; i++) {
+ if ((p - i) > 0) {
+ email[p-i] = '.';
+ }
+ }
+
+ return email;
+}
+
/*
* This function prints one message
*/
static void print_message(request_rec *r, char* baseURI, Message *m)
{
+ dir_cfg *conf;
+ char *from;
+
+ conf = ap_get_module_config(r->per_dir_config, &mbox_module);
+ from = ESCAPE_OF_BLANK(r->pool, m->str_from);
+
+ if (conf->antispam) {
+ from = email_antispam(from);
+ }
+
/* FIXME: HTML or TEXT formats? */
ap_rprintf(r, "<A HREF=\"%s/%s\">%s</A> %s (%s)",
- baseURI,
+ baseURI,
URI_ESCAPE_OR_BLANK(r->pool, m->msgID),
ESCAPE_OR_BLANK(r->pool, m->subject),
- ESCAPE_OR_BLANK(r->pool, m->str_from),
+ from,
ESCAPE_OR_BLANK(r->pool, m->str_date));
}
@@ -836,9 +872,11 @@
apr_bucket *b;
mbox_filter_ctx *ctx = f->ctx;
Message *m = ctx->m;
- char *baseURI, *temp;
+ char *baseURI, *temp, *from;
+ dir_cfg *conf;
+
+ conf = ap_get_module_config(f->r->per_dir_config, &mbox_module);
-
/* We want to be nice and display a link back to the index from whence
* they came. We want the NON r->path_info part, but that isn't a
* part of the request_rec (no reason why not - could be added?) - so
@@ -869,6 +907,11 @@
ctx->tbb = apr_brigade_create(f->r->pool, f->c->bucket_alloc);
temp = URI_ESCAPE_OR_BLANK(f->r->pool, m->msgID);
+ from = ESCAPE_OR_BLANK(f->r->pool, m->from);
+
+ if (conf->antispam) {
+ from = email_antispam(from);
+ }
apr_brigade_printf(ctx->tbb, NULL, NULL,
DOCTYPE_HTML_4_0T
@@ -887,7 +930,7 @@
"<HR>\n<PRE>\n",
ap_escape_html(f->r->pool, m->subject),
ctx->baseURI, ctx->baseURI, ctx->baseURI,
- ESCAPE_OR_BLANK(f->r->pool, m->from),
+ from,
ESCAPE_OR_BLANK(f->r->pool, m->subject),
ESCAPE_OR_BLANK(f->r->pool, m->str_date),
ctx->baseURI, temp,
Index: module-2.0/mod_mbox.c
===================================================================
--- module-2.0/mod_mbox.c (revision 188736)
+++ module-2.0/mod_mbox.c (working copy)
@@ -82,6 +82,7 @@
dir_cfg *conf = apr_pcalloc(p, sizeof(dir_cfg));
conf->enabled = 0;
+ conf->antispam = 0;
conf->search_path = NULL;
return conf;
@@ -100,6 +101,13 @@
to->enabled = from->enabled;
}
+ if (merge->antispam == 1) {
+ to->antispam = 1;
+ }
+ else {
+ to->antispam = from->antispam;
+ }
+
if (merge->search_path != NULL) {
to->search_path = apr_pstrdup(p, merge->search_path);
}
@@ -117,6 +125,9 @@
AP_INIT_FLAG("mboxindex", ap_set_flag_slot,
(void *)APR_OFFSETOF(dir_cfg, enabled), OR_INDEXES,
"Enable mod_mbox to create directory listings of .mbox
files."),
+ AP_INIT_FLAG("mboxantispam", ap_set_flag_slot,
+ (void *)APR_OFFSETOF(dir_cfg, antispam), OR_INDEXES,
+ "Enable mod_mbox email obfuscation."),
AP_INIT_TAKE1("mboxsearch", ap_set_string_slot,
(void *)APR_OFFSETOF(dir_cfg, search_path), OR_INDEXES,
"Set the Directory that contains Search Data"),
Index: module-2.0/mod_mbox.h
===================================================================
--- module-2.0/mod_mbox.h (revision 188736)
+++ module-2.0/mod_mbox.h (working copy)
@@ -69,6 +69,7 @@
typedef struct dir_cfg {
int enabled;
+ int antispam;
const char* search_path;
} dir_cfg;
signature.asc
Description: Digital signature
