diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Msgmap.pm | 4 | ||||
-rw-r--r-- | lib/PublicInbox/SearchView.pm | 18 | ||||
-rw-r--r-- | lib/PublicInbox/WwwListing.pm | 14 |
3 files changed, 31 insertions, 5 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index 0035c9e3..5a89b85a 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -126,9 +126,9 @@ sub mid_insert { my ($self, $mid) = @_; my $dbh = $self->{dbh}; my $sth = $dbh->prepare_cached(<<''); -INSERT OR IGNORE INTO msgmap (mid) VALUES (?) +INSERT INTO msgmap (mid) VALUES (?) - return if $sth->execute($mid) == 0; + return unless eval { $sth->execute($mid) }; my $num = $dbh->last_insert_id(undef, undef, 'msgmap', 'num'); $self->num_highwater($num) if defined($num); $num; diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 6f07279b..a8b66dda 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -15,6 +15,7 @@ use PublicInbox::MIME; require PublicInbox::Git; require PublicInbox::SearchThread; our $LIM = 200; +my %rmap_inc; sub noop {} @@ -138,10 +139,27 @@ sub mset_summary { *noop; } +# shorten "/full/path/to/Foo/Bar.pm" to "Foo/Bar.pm" so error +# messages don't reveal FS layout info in case people use non-standard +# installation paths +sub path2inc ($) { + my $full = $_[0]; + if (my $short = $rmap_inc{$full}) { + return $short; + } elsif (!scalar(keys %rmap_inc) && -e $full) { + %rmap_inc = map {; "$INC{$_}" => $_ } keys %INC; + # fall back to basename as last resort + $rmap_inc{$full} // (split('/', $full))[-1]; + } else { + $full; + } +} + sub err_txt { my ($ctx, $err) = @_; my $u = $ctx->{-inbox}->base_url($ctx->{env}) . '_/text/help/'; $err =~ s/^\s*Exception:\s*//; # bad word to show users :P + $err =~ s!(\S+)!path2inc($1)!sge; $err = ascii_html($err); "\nBad query: <b>$err</b>\n" . qq{See <a\nhref="$u">$u</a> for help on using search}; diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index e052bbff..1d4029f0 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -138,8 +138,8 @@ sub fingerprint ($) { $dig->hexdigest; } -sub manifest_add ($$;$) { - my ($manifest, $ibx, $epoch) = @_; +sub manifest_add ($$;$$) { + my ($manifest, $ibx, $epoch, $default_desc) = @_; my $url_path = "/$ibx->{name}"; my $git_dir = $ibx->{mainrepo}; if (defined $epoch) { @@ -155,6 +155,13 @@ sub manifest_add ($$;$) { $owner = undef if $owner eq ''; $desc = 'Unnamed repository' if $desc eq ''; + # templates/hooks--update.sample and git-multimail in git.git + # only match "Unnamed repository", not the full contents of + # templates/this--description in git.git + if ($desc =~ /\AUnnamed repository/) { + $desc = "$default_desc [epoch $epoch]" if defined($epoch); + } + my $reference; chomp(my $alt = try_cat("$git_dir/objects/info/alternates")); if ($alt) { @@ -191,8 +198,9 @@ sub js ($$) { my $manifest = { -abs2urlpath => {}, -mtime => 0 }; for my $ibx (@$list) { if (defined(my $max = $ibx->max_git_epoch)) { + my $desc = $ibx->description; for my $epoch (0..$max) { - manifest_add($manifest, $ibx, $epoch); + manifest_add($manifest, $ibx, $epoch, $desc); } } else { manifest_add($manifest, $ibx); |