user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: meta@public-inbox.org
Subject: [PATCH 1/5] viewvcs: allow "0" as a path name
Date: Tue,  7 Jul 2020 20:37:34 +0000	[thread overview]
Message-ID: <20200707203738.32677-2-e@yhbt.net> (raw)
In-Reply-To: <20200707203738.32677-1-e@yhbt.net>

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 | 6 ++++--
 lib/PublicInbox/WWW.pm     | 5 ++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 9ec04f480..053848a8b 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -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");
diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm
index e4ad515a4..2ea5d80db 100644
--- a/lib/PublicInbox/WWW.pm
+++ b/lib/PublicInbox/WWW.pm
@@ -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);

  reply	other threads:[~2020-07-07 20:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 20:37 [PATCH 0/5] uninitialized vs blank fixes Eric Wong
2020-07-07 20:37 ` Eric Wong [this message]
2020-07-07 20:37 ` [PATCH 2/5] hval: to_filename: return `undef' instead of empty string Eric Wong
2020-07-07 20:37 ` [PATCH 3/5] viewvcs: stop checking unused "B" query parameter Eric Wong
2020-07-07 20:37 ` [PATCH 4/5] imap: avoid warnings on non-slice mailboxes Eric Wong
2020-07-07 20:37 ` [PATCH 5/5] wwwatomstream: avoid uninitialized warnings for $email Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200707203738.32677-2-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).