Author: Martin Szulecki <opensuse@sukimashita.com>
Introduce noplainemail option to hide email adresses from spambots Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
cgit.c | 2 ++ cgit.h | 1 + cgitrc.5.txt | 4 ++++ ui-atom.c | 2 +- ui-commit.c | 12 ++++++++---- ui-patch.c | 6 +++++- ui-tag.c | 2 +-
diff --git a/cgit.c b/cgit.c index 2039ab1de53699b6d29a23f1409461386589a227..f6bb0c7ed01bdb8402ce26c4490609a21e24e4d4 100644 --- a/cgit.c +++ b/cgit.c @@ -51,6 +51,8 @@ if (!ctx.cfg.virtual_root && (!strcmp(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 --- a/cgit.h +++ b/cgit.h @@ -168,6 +168,7 @@ int max_msg_len; int max_repodesc_len; int max_stats; int nocache; + int noplainemail; int noheader; int renamelimit; int snapshots; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index a207fe07aadb9eb2863b1c47165e804772a12e5b..77549236072347a9d2c95301f188f822e117e4ba 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -158,6 +158,10 @@ If set to the value "1" caching will be disabled. This settings is 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". diff --git a/ui-atom.c b/ui-atom.c index e5c31d9dd066fd7e7a63da846ab6add0b9aea0e6..808b2d0abede36fc73c8633ba36044a9d5547c30 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -32,7 +32,7 @@ html(""); 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) diff --git a/ui-commit.c b/ui-commit.c index 41ce70e2a9964839b5bf8f03ba6698b7d1ac69d1..9fdb8eed4d2118c968571db50839bac55f0f7c3f 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -40,15 +40,19 @@ 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"); diff --git a/ui-patch.c b/ui-patch.c index 5d665d3edbe826c01705ef7f009d045860b6e243..2a8f7a573ca8433bdc1e46dcca444202a4431d46 100644 --- a/ui-patch.c +++ b/ui-patch.c @@ -108,7 +108,11 @@ ctx.page.mimetype = "text/plain"; 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); diff --git a/ui-tag.c b/ui-tag.c index 0e056e016092f53c508d86cdefd3e76f0fcb7d36..a9c867070f9c71a042a99ae7c3a4ddc85dbd5ae5 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -64,7 +64,7 @@ } 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); }