]> Sergey Matveev's repositories - public-inbox.git/commitdiff
viewvcs: allow "0" as a path name
authorEric Wong <e@yhbt.net>
Tue, 7 Jul 2020 20:37:34 +0000 (20:37 +0000)
committerEric Wong <e@yhbt.net>
Fri, 10 Jul 2020 11:27:05 +0000 (11:27 +0000)
This means we need to filter out "" from query parameters.
While we're at it, update comments for the WWW endpoint.

lib/PublicInbox/ViewVCS.pm
lib/PublicInbox/WWW.pm

index 9ec04f480a09abb628405ec47cfe3a816c54476d..053848a8b49f2a51ad6f283648ce56a65881c825 100644 (file)
@@ -127,7 +127,7 @@ sub solve_result {
 
        my ($git, $oid, $type, $size, $di) = @$res;
        return show_other($ctx, $res, \$log, $fn) if $type ne 'blob';
-       my $path = to_filename($di->{path_b} || $hints->{path_b} || 'blob');
+       my $path = to_filename($di->{path_b} // $hints->{path_b} // 'blob');
        my $raw_link = "(<a\nhref=$path>raw</a>)";
        if ($size > $MAX_SIZE) {
                return stream_large_blob($ctx, $res, \$log, $fn) if defined $fn;
@@ -184,13 +184,15 @@ sub solve_result {
        html_page($ctx, 200, \$log);
 }
 
+# GET /$INBOX/$GIT_OBJECT_ID/s/
+# GET /$INBOX/$GIT_OBJECT_ID/s/$FILENAME
 sub show ($$;$) {
        my ($ctx, $oid_b, $fn) = @_;
        my $qp = $ctx->{qp};
        my $hints = $ctx->{hints} = {};
        while (my ($from, $to) = each %QP_MAP) {
                defined(my $v = $qp->{$from}) or next;
-               $hints->{$to} = $v;
+               $hints->{$to} = $v if $v ne '';
        }
 
        $ctx->{'log'} = tmpfile("solve.$oid_b");
index e4ad515a4d341d03ef5014f18d0a783c44c8fb31..2ea5d80db7817a8d2d12a94f5f1b38c6c92833b1 100644 (file)
@@ -301,9 +301,8 @@ sub get_text {
 }
 
 # show git objects (blobs and commits)
-# /$INBOX/_/$OBJECT_ID/show
-# /$INBOX/_/${OBJECT_ID}_${FILENAME}
-# KEY may contain slashes
+# /$INBOX/$GIT_OBJECT_ID/s/
+# /$INBOX/$GIT_OBJECT_ID/s/$FILENAME
 sub get_vcs_object ($$$;$) {
        my ($ctx, $inbox, $oid, $filename) = @_;
        my $r404 = invalid_inbox($ctx, $inbox);