From: Eric Wong Date: Wed, 30 Jan 2019 07:40:35 +0000 (+0000) Subject: Merge remote-tracking branch 'origin/viewvcs' into master X-Git-Tag: v1.2.0~397 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=cf439203c31836e4c48f632f902aa58db6924972;hp=11f984fa36647b0ab107596bcec2dd9b963f1379 Merge remote-tracking branch 'origin/viewvcs' into master * origin/viewvcs: (66 commits) solvergit: deal with alternative diff prefixes solvergit: extract mode from diff headers properly solvergit: avoid "Wide character" warnings solvergit: do not show full path names to "git apply" css/216dark: add comments and tweak highlight colors viewvcs: avoid segfault with highlight.pm at shutdown solvergit: do not solve blobs twice t/check-www-inbox: disable history t/check-www-inbox: don't follow mboxes t/check-www-inbox: replace IPC::Run with PublicInbox::Spawn hval: add src_escape for highlight post-processing viewvcs: wire up syntax-highlighting for blobs hlmod: disable enclosing
 tag
  t/hl_mod: extra check to ensure we escape HTML
  wwwhighlight: read_in_full returns undef on errors
  solver: crank up max patches to 9999
  viewvcs: do not show final error message twice
  qspawn: decode $? for user-friendliness
  solver: reduce "git apply" invocations
  solver: hold patches in temporary directory
  ...
---

diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm
index 51e7799d..14d49cc5 100644
--- a/lib/PublicInbox/ExtMsg.pm
+++ b/lib/PublicInbox/ExtMsg.pm
@@ -11,6 +11,7 @@ use warnings;
 use PublicInbox::Hval;
 use PublicInbox::MID qw/mid2path/;
 use PublicInbox::WwwStream;
+our $MIN_PARTIAL_LEN = 16;
 
 # TODO: user-configurable
 our @EXT_URL = (
@@ -30,6 +31,7 @@ sub PARTIAL_MAX () { 100 }
 
 sub search_partial ($$) {
 	my ($srch, $mid) = @_;
+	return if length($mid) < $MIN_PARTIAL_LEN;
 	my $opt = { limit => PARTIAL_MAX, mset => 2 };
 	my @try = ("m:$mid*");
 	my $chop = $mid;
@@ -58,12 +60,12 @@ sub search_partial ($$) {
 	}
 
 	foreach my $m (@try) {
-		my $mset = eval { $srch->query($m, $opt) };
-		if (ref($@) eq 'Search::Xapian::QueryParserError') {
-			# If Xapian can't handle the wildcard since it
-			# has too many results.
-			next;
-		}
+		# If Xapian can't handle the wildcard since it
+		# has too many results.  $@ can be
+		# Search::Xapian::QueryParserError or even:
+		# "something terrible happened at ../Search/Xapian/Enquire.pm"
+		my $mset = eval { $srch->query($m, $opt) } or next;
+
 		my @mids = map {
 			my $doc = $_->get_document;
 			PublicInbox::SearchMsg->load_doc($doc)->mid;
@@ -112,7 +114,7 @@ sub ext_msg {
 	}
 
 	# can't find a partial match in current inbox, try the others:
-	if (!$n_partial && length($mid) >= 16) {
+	if (!$n_partial && length($mid) >= $MIN_PARTIAL_LEN) {
 		foreach my $ibx (@ibx) {
 			$srch = $ibx->search or next;
 			$mids = search_partial($srch, $mid) or next;
diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm
index 38517710..b0bf94ad 100644
--- a/lib/PublicInbox/HTTPD.pm
+++ b/lib/PublicInbox/HTTPD.pm
@@ -29,9 +29,16 @@ sub new {
 		'psgi.run_once'	 => Plack::Util::FALSE,
 		'psgi.multithread' => Plack::Util::FALSE,
 		'psgi.multiprocess' => Plack::Util::TRUE,
+
+		# We don't use this anywhere, but we can support
+		# other PSGI apps which might use it:
 		'psgix.input.buffered' => Plack::Util::TRUE,
 
-		# XXX unstable API!
+		# XXX unstable API!, only GitHTTPBackend needs
+		# this to limit git-http-backend(1) parallelism.
+		# The rest of our PSGI code is generic, relying
+		# on "pull" model using "getline" to prevent
+		# over-buffering.
 		'pi-httpd.async' => do {
 			no warnings 'once';
 			*pi_httpd_async
diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index cd56f272..7f1ab15e 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -10,6 +10,7 @@ our @EXPORT_OK = qw/mid_clean id_compress mid2path mid_mime mid_escape MID_ESC
 	mids references/;
 use URI::Escape qw(uri_escape_utf8);
 use Digest::SHA qw/sha1_hex/;
+require PublicInbox::Address;
 use constant {
 	MID_MAX => 40, # SHA-1 hex length # TODO: get rid of this
 	MAX_MID_SIZE => 244, # max term size (Xapian limitation) - length('Q')
@@ -79,22 +80,34 @@ sub references ($) {
 			push(@mids, ($v =~ /<([^>]+)>/sg));
 		}
 	}
-	uniq_mids(\@mids);
+
+	# old versions of git-send-email would prompt users for
+	# In-Reply-To and users' muscle memory would use 'y' or 'n'
+	# as responses:
+	my %addr = ( y => 1, n => 1 );
+
+	foreach my $f (qw(To From Cc)) {
+		my @v = $hdr->header_raw($f);
+		foreach my $v (@v) {
+			$addr{$_} = 1 for (PublicInbox::Address::emails($v));
+		}
+	}
+	uniq_mids(\@mids, \%addr);
 }
 
-sub uniq_mids ($) {
-	my ($mids) = @_;
+sub uniq_mids ($;$) {
+	my ($mids, $seen) = @_;
 	my @ret;
-	my %seen;
+	$seen ||= {};
 	foreach my $mid (@$mids) {
 		$mid =~ tr/\n\t\r//d;
 		if (length($mid) > MAX_MID_SIZE) {
 			warn "Message-ID: <$mid> too long, truncating\n";
 			$mid = substr($mid, 0, MAX_MID_SIZE);
 		}
-		next if $seen{$mid};
+		next if $seen->{$mid};
 		push @ret, $mid;
-		$seen{$mid} = 1;
+		$seen->{$mid} = 1;
 	}
 	\@ret;
 }
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 5aaa72ba..ca9b9550 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -896,11 +896,6 @@ sub missing_thread {
 	PublicInbox::ExtMsg::ext_msg($ctx);
 }
 
-sub _msg_date {
-	my ($hdr) = @_;
-	fmt_ts(msg_datestamp($hdr));
-}
-
 sub fmt_ts { POSIX::strftime('%Y-%m-%d %k:%M', gmtime($_[0])) }
 
 sub dedupe_subject {
diff --git a/t/mid.t b/t/mid.t
index 8c307c82..69a8a708 100644
--- a/t/mid.t
+++ b/t/mid.t
@@ -36,6 +36,10 @@ is(mid_escape('foo%!@(bar)'), 'foo%25!@(bar)');
 	$mime->header_set('Message-ID', "");
 	is_deeply(mids($mime->header_obj), ['helloworld'],
 		'drop \t in Message-ID');
+
+	$mime->header_set('To', 'u@example.com');
+	$mime->header_set('References', '   ');
+	is_deeply(references($mime->header_obj), [qw(hello world)]);
 }
 
 done_testing();