Skip to contentSkip to conversation

gitweb: Require project for all actions except few

PATCH In review Jakub Narebski 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Require project for all actions except few

Require that project (repository) is given for all actions except project_list, project_index and opml.

---
 gitweb/gitweb.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +4 -0
index 034cdf1..34311ee 100755
@@ -341,6 +341,10 @@ if (defined $project) {
 if (!defined($actions{$action})) {
 	die_error(undef, "Unknown action");
 }
+if ($action !~ m/^opml|project_list|project_index$/ &&
+    !$project) {
+	die_error(undef, "Project needed");
+}
 $actions{$action}->();
 exit;
 
Signature · 1 line
1.4.2.1
#1 lore raw
Quoted 1 line · Jakub Narebski

+if ($action !~ m/^opml|project_list|project_index$/ &&

The regexp should be:
m/^(opml|project_list|project_index)$/ &&

% (echo opml_foo; echo foo_project_list_bar; echo bar_project_index) |
perl -ne 'print if m/^opml|project_list|project_index$/;'
opml_foo
foo_project_list_bar
bar_project_index