about summary refs log tree commit homepage
path: root/lib/PublicInbox/RepoGitFallback.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-02-09 01:37:03 +0000
committerEric Wong <e@80x24.org>2017-02-09 01:37:03 +0000
commitd9563ea5516e8e786debf223e10ec11695aee9d7 (patch)
treea0842b1ee0953bc8e65d21d5d96432f41973adb7 /lib/PublicInbox/RepoGitFallback.pm
parentfb9ed5324ec7de9420956840ba9a6585b81e8231 (diff)
downloadpublic-inbox-d9563ea5516e8e786debf223e10ec11695aee9d7.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/RepoGitFallback.pm')
-rw-r--r--lib/PublicInbox/RepoGitFallback.pm21
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..5ce469be
--- /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_info}->{git};
+        PublicInbox::GitHTTPBackend::serve($req->{env}, $git, $expath);
+}
+
+1;