Introduce noplainemail option to hide email adresses from spambots
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
This commit is contained in:
		
							
								
								
									
										2
									
								
								cgit.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								cgit.c
									
									
									
									
									
								
							@@ -51,6 +51,8 @@ void config_cb(const char *name, const char *value)
 | 
				
			|||||||
			ctx.cfg.virtual_root = "";
 | 
								ctx.cfg.virtual_root = "";
 | 
				
			||||||
	} else if (!strcmp(name, "nocache"))
 | 
						} else if (!strcmp(name, "nocache"))
 | 
				
			||||||
		ctx.cfg.nocache = atoi(value);
 | 
							ctx.cfg.nocache = atoi(value);
 | 
				
			||||||
 | 
						else if (!strcmp(name, "noplainemail"))
 | 
				
			||||||
 | 
							ctx.cfg.noplainemail = atoi(value);
 | 
				
			||||||
	else if (!strcmp(name, "noheader"))
 | 
						else if (!strcmp(name, "noheader"))
 | 
				
			||||||
		ctx.cfg.noheader = atoi(value);
 | 
							ctx.cfg.noheader = atoi(value);
 | 
				
			||||||
	else if (!strcmp(name, "snapshots"))
 | 
						else if (!strcmp(name, "snapshots"))
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								cgit.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								cgit.h
									
									
									
									
									
								
							@@ -168,6 +168,7 @@ struct cgit_config {
 | 
				
			|||||||
	int max_repodesc_len;
 | 
						int max_repodesc_len;
 | 
				
			||||||
	int max_stats;
 | 
						int max_stats;
 | 
				
			||||||
	int nocache;
 | 
						int nocache;
 | 
				
			||||||
 | 
						int noplainemail;
 | 
				
			||||||
	int noheader;
 | 
						int noheader;
 | 
				
			||||||
	int renamelimit;
 | 
						int renamelimit;
 | 
				
			||||||
	int snapshots;
 | 
						int snapshots;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -158,6 +158,10 @@ nocache::
 | 
				
			|||||||
	deprecated, and will not be honored starting with cgit-1.0. Default
 | 
						deprecated, and will not be honored starting with cgit-1.0. Default
 | 
				
			||||||
	value: "0".
 | 
						value: "0".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					noplainemail::
 | 
				
			||||||
 | 
						If set to "1" showing full author email adresses will be disabled.
 | 
				
			||||||
 | 
						Default value: "0".
 | 
				
			||||||
 | 
					
 | 
				
			||||||
noheader::
 | 
					noheader::
 | 
				
			||||||
	Flag which, when set to "1", will make cgit omit the standard header
 | 
						Flag which, when set to "1", will make cgit omit the standard header
 | 
				
			||||||
	on all pages. Default value: none. See also: "embedded".
 | 
						on all pages. Default value: none. See also: "embedded".
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@ void add_entry(struct commit *commit, char *host)
 | 
				
			|||||||
		html_txt(info->author);
 | 
							html_txt(info->author);
 | 
				
			||||||
		html("</name>\n");
 | 
							html("</name>\n");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (info->author_email) {
 | 
						if (info->author_email && !ctx.cfg.noplainemail) {
 | 
				
			||||||
		mail = xstrdup(info->author_email);
 | 
							mail = xstrdup(info->author_email);
 | 
				
			||||||
		t = strchr(mail, '<');
 | 
							t = strchr(mail, '<');
 | 
				
			||||||
		if (t)
 | 
							if (t)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,15 +40,19 @@ void cgit_print_commit(char *hex)
 | 
				
			|||||||
	html("<table summary='commit info' class='commit-info'>\n");
 | 
						html("<table summary='commit info' class='commit-info'>\n");
 | 
				
			||||||
	html("<tr><th>author</th><td>");
 | 
						html("<tr><th>author</th><td>");
 | 
				
			||||||
	html_txt(info->author);
 | 
						html_txt(info->author);
 | 
				
			||||||
 | 
						if (!ctx.cfg.noplainemail) {
 | 
				
			||||||
		html(" ");
 | 
							html(" ");
 | 
				
			||||||
		html_txt(info->author_email);
 | 
							html_txt(info->author_email);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	html("</td><td class='right'>");
 | 
						html("</td><td class='right'>");
 | 
				
			||||||
	cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
 | 
						cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
 | 
				
			||||||
	html("</td></tr>\n");
 | 
						html("</td></tr>\n");
 | 
				
			||||||
	html("<tr><th>committer</th><td>");
 | 
						html("<tr><th>committer</th><td>");
 | 
				
			||||||
	html_txt(info->committer);
 | 
						html_txt(info->committer);
 | 
				
			||||||
 | 
						if (!ctx.cfg.noplainemail) {
 | 
				
			||||||
		html(" ");
 | 
							html(" ");
 | 
				
			||||||
		html_txt(info->committer_email);
 | 
							html_txt(info->committer_email);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	html("</td><td class='right'>");
 | 
						html("</td><td class='right'>");
 | 
				
			||||||
	cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
 | 
						cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
 | 
				
			||||||
	html("</td></tr>\n");
 | 
						html("</td></tr>\n");
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -108,7 +108,11 @@ void cgit_print_patch(char *hex)
 | 
				
			|||||||
	ctx.page.filename = patchname;
 | 
						ctx.page.filename = patchname;
 | 
				
			||||||
	cgit_print_http_headers(&ctx);
 | 
						cgit_print_http_headers(&ctx);
 | 
				
			||||||
	htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
 | 
						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: ");
 | 
						html("Date: ");
 | 
				
			||||||
	cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
 | 
						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);
 | 
						htmlf("Subject: %s\n\n", info->subject);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								ui-tag.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								ui-tag.c
									
									
									
									
									
								
							@@ -64,7 +64,7 @@ void cgit_print_tag(char *revname)
 | 
				
			|||||||
		if (info->tagger) {
 | 
							if (info->tagger) {
 | 
				
			||||||
			html("<tr><td>Tagged by</td><td>");
 | 
								html("<tr><td>Tagged by</td><td>");
 | 
				
			||||||
			html_txt(info->tagger);
 | 
								html_txt(info->tagger);
 | 
				
			||||||
			if (info->tagger_email) {
 | 
								if (info->tagger_email && !ctx.cfg.noplainemail) {
 | 
				
			||||||
				html(" ");
 | 
									html(" ");
 | 
				
			||||||
				html_txt(info->tagger_email);
 | 
									html_txt(info->tagger_email);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user