diff options
Diffstat (limited to 'lib/PublicInbox/RepoGitFallback.pm')
-rw-r--r-- | lib/PublicInbox/RepoGitFallback.pm | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/PublicInbox/RepoGitFallback.pm b/lib/PublicInbox/RepoGitFallback.pm new file mode 100644 index 00000000..8675d0d7 --- /dev/null +++ b/lib/PublicInbox/RepoGitFallback.pm @@ -0,0 +1,21 @@ +# Copyright (C) 2015 all contributors <meta@public-inbox.org> +# 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}->{git}; + PublicInbox::GitHTTPBackend::serve($req->{env}, $git, $expath); +} + +1; |