]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Merge remote-tracking branch 'origin/viewvcs' into master
authorEric Wong <e@80x24.org>
Wed, 30 Jan 2019 07:40:35 +0000 (07:40 +0000)
committerEric Wong <e@80x24.org>
Wed, 30 Jan 2019 07:40:35 +0000 (07:40 +0000)
* 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 <pre> 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
  ...

lib/PublicInbox/ExtMsg.pm
lib/PublicInbox/HTTPD.pm
lib/PublicInbox/MID.pm
lib/PublicInbox/View.pm
t/mid.t

index 51e7799de8640929be9538713d3f2ee7e1b1081d..14d49cc59e186c8102fe60eda13513c767a2fa94 100644 (file)
@@ -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;
index 38517710a414d00ee36d21b069de90953ffa4b08..b0bf94adf7dda314d3d4bb2d134874334d1d5b75 100644 (file)
@@ -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
index cd56f272613dc28551409593545eec5a2e80eb0e..7f1ab15ea731db8f0f70304662afe338754b5c6c 100644 (file)
@@ -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;
 }
index 5aaa72ba1fd9be0c8f8b5b69329fc34757732aa4..ca9b95505f6c767784d77023d8ec5fe500cf1a7e 100644 (file)
@@ -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 8c307c825d22a7e2747c8f35fb1df0909c798dcb..69a8a708ec0b623a2db296ff9b0e56a2bba26233 100644 (file)
--- 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', "<hello\tworld>");
        is_deeply(mids($mime->header_obj), ['helloworld'],
                'drop \t in Message-ID');
+
+       $mime->header_set('To', 'u@example.com');
+       $mime->header_set('References', '<hello> <world> <n> <u@example.com>');
+       is_deeply(references($mime->header_obj), [qw(hello world)]);
 }
 
 done_testing();