use File::Basename qw(basename);
use Time::HiRes qw(gettimeofday tv_interval);
use Digest::MD5 qw(md5_hex);
+use Git::LoadCPAN::Mail::Address;
binmode STDOUT, ':utf8';
return %date;
}
+sub is_mailaddr {
+ my @addrs = Mail::Address->parse(shift);
+ if (!@addrs || !$addrs[0]->host || !$addrs[0]->user) {
+ return 0;
+ }
+ return 1;
+}
+
sub hide_mailaddrs_if_private {
my $line = shift;
return $line unless gitweb_check_feature('email-privacy');
- $line =~ s/<[^@>]+@[^>]+>/<redacted>/g;
+ while ($line =~ m/(<[^>]+>)/g) {
+ my $match = $1;
+ if (!is_mailaddr($match)) {
+ next;
+ }
+ my $match_offset = pos($line) - length($match);
+ pos $line = $match_offset;
+
+ my $redaction = "<redacted>";
+ $line =~ s/\G(<[^>]+>)/$redaction/;
+
+ pos $line = $match_offset + length($redaction);
+ }
return $line;
}
GITWEB_CONFIG=$(pwd)/gitweb_config.perl
export GITWEB_CONFIG
+ PERL5LIB="$GIT_BUILD_DIR/perl:$GIT_BUILD_DIR/perl/FromCPAN"
+ export PERL5LIB
+
# some of git commands write to STDERR on error, but this is not
# written to web server logs, so we are not interested in that:
# we are interested only in properly formatted errors/warnings