From d9563ea5516e8e786debf223e10ec11695aee9d7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 9 Feb 2017 01:37:03 +0000 Subject: repobrowse: shorten internal names We'll still be keeping "repobrowse" for the public API for use with .psgi files, but shortening the name means less typing and we may have command-line tools, too. --- lib/PublicInbox/RepoGitFallback.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/PublicInbox/RepoGitFallback.pm (limited to 'lib/PublicInbox/RepoGitFallback.pm') diff --git a/lib/PublicInbox/RepoGitFallback.pm b/lib/PublicInbox/RepoGitFallback.pm new file mode 100644 index 00000000..5ce469be --- /dev/null +++ b/lib/PublicInbox/RepoGitFallback.pm @@ -0,0 +1,21 @@ +# Copyright (C) 2015 all contributors +# License: AGPL-3.0+ (https://www.gnu.org/licenses/agpl-3.0.txt) + +# when no endpoints match, fallback to this and serve a static file +# This can serve Smart HTTP in the future. +package PublicInbox::RepoGitFallback; +use strict; +use warnings; +use base qw(PublicInbox::RepoBase); +use PublicInbox::GitHTTPBackend; + +# overrides PublicInbox::RepoBase::call +sub call { + my ($self, undef, $req) = @_; + my $expath = $req->{expath}; + return if index($expath, '..') >= 0; # prevent path traversal + my $git = $req->{repo_info}->{git}; + PublicInbox::GitHTTPBackend::serve($req->{env}, $git, $expath); +} + +1; -- cgit v1.2.3-24-ge0c7