]> granicus.if.org Git - cgit/commitdiff
Introduce noplainemail option to hide email adresses from spambots
authorMartin Szulecki <opensuse@sukimashita.com>
Fri, 7 Aug 2009 12:05:17 +0000 (14:05 +0200)
committerMartin Szulecki <opensuse@sukimashita.com>
Sat, 8 Aug 2009 12:23:28 +0000 (14:23 +0200)
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
cgit.c
cgit.h
cgitrc.5.txt
ui-atom.c
ui-commit.c
ui-patch.c
ui-tag.c

diff --git a/cgit.c b/cgit.c
index 2039ab1de53699b6d29a23f1409461386589a227..f6bb0c7ed01bdb8402ce26c4490609a21e24e4d4 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -51,6 +51,8 @@ void config_cb(const char *name, const char *value)
                        ctx.cfg.virtual_root = "";
        } else if (!strcmp(name, "nocache"))
                ctx.cfg.nocache = atoi(value);
+       else if (!strcmp(name, "noplainemail"))
+               ctx.cfg.noplainemail = atoi(value);
        else if (!strcmp(name, "noheader"))
                ctx.cfg.noheader = atoi(value);
        else if (!strcmp(name, "snapshots"))
diff --git a/cgit.h b/cgit.h
index 8c64efeaa6e7f5698751e202b64765280e3985cf..acb5e8fd52ff1e9a1e8e16dbcbb10569cef36a74 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -168,6 +168,7 @@ struct cgit_config {
        int max_repodesc_len;
        int max_stats;
        int nocache;
+       int noplainemail;
        int noheader;
        int renamelimit;
        int snapshots;
index a207fe07aadb9eb2863b1c47165e804772a12e5b..77549236072347a9d2c95301f188f822e117e4ba 100644 (file)
@@ -158,6 +158,10 @@ nocache::
        deprecated, and will not be honored starting with cgit-1.0. Default
        value: "0".
 
+noplainemail::
+       If set to "1" showing full author email adresses will be disabled.
+       Default value: "0".
+
 noheader::
        Flag which, when set to "1", will make cgit omit the standard header
        on all pages. Default value: none. See also: "embedded".
index e5c31d9dd066fd7e7a63da846ab6add0b9aea0e6..808b2d0abede36fc73c8633ba36044a9d5547c30 100644 (file)
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -32,7 +32,7 @@ void add_entry(struct commit *commit, char *host)
                html_txt(info->author);
                html("</name>\n");
        }
-       if (info->author_email) {
+       if (info->author_email && !ctx.cfg.noplainemail) {
                mail = xstrdup(info->author_email);
                t = strchr(mail, '<');
                if (t)
index 41ce70e2a9964839b5bf8f03ba6698b7d1ac69d1..9fdb8eed4d2118c968571db50839bac55f0f7c3f 100644 (file)
@@ -40,15 +40,19 @@ void cgit_print_commit(char *hex)
        html("<table summary='commit info' class='commit-info'>\n");
        html("<tr><th>author</th><td>");
        html_txt(info->author);
-       html(" ");
-       html_txt(info->author_email);
+       if (!ctx.cfg.noplainemail) {
+               html(" ");
+               html_txt(info->author_email);
+       }
        html("</td><td class='right'>");
        cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
        html("</td></tr>\n");
        html("<tr><th>committer</th><td>");
        html_txt(info->committer);
-       html(" ");
-       html_txt(info->committer_email);
+       if (!ctx.cfg.noplainemail) {
+               html(" ");
+               html_txt(info->committer_email);
+       }
        html("</td><td class='right'>");
        cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
        html("</td></tr>\n");
index 5d665d3edbe826c01705ef7f009d045860b6e243..2a8f7a573ca8433bdc1e46dcca444202a4431d46 100644 (file)
@@ -108,7 +108,11 @@ void cgit_print_patch(char *hex)
        ctx.page.filename = patchname;
        cgit_print_http_headers(&ctx);
        htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
-       htmlf("From: %s %s\n", info->author, info->author_email);
+       htmlf("From: %s", info->author);
+       if (!ctx.cfg.noplainemail) {
+               htmlf(" %s", info->author_email);
+       }
+       html("\n");
        html("Date: ");
        cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
        htmlf("Subject: %s\n\n", info->subject);
index 0e056e016092f53c508d86cdefd3e76f0fcb7d36..a9c867070f9c71a042a99ae7c3a4ddc85dbd5ae5 100644 (file)
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -64,7 +64,7 @@ void cgit_print_tag(char *revname)
                if (info->tagger) {
                        html("<tr><td>Tagged by</td><td>");
                        html_txt(info->tagger);
-                       if (info->tagger_email) {
+                       if (info->tagger_email && !ctx.cfg.noplainemail) {
                                html(" ");
                                html_txt(info->tagger_email);
                        }