{"thread":{"id":"5578","subject":"[PATCH] gitweb: export-ok option","startedAt":"2006-09-16T19:27:50Z","lastAt":"2006-09-17T23:10:52Z","messageCount":15,"participants":["Matthias Lederhofer","Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"27011","messageId":"20060916192750.GA27008@moooo.ath.cx","threadId":"5578","inReplyTo":null,"subject":"[PATCH] gitweb: export-ok option","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-16T19:27:50Z","receivedAt":"2006-09-16T19:27:50Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Similar to git-daemon checking for git-daemon-export-ok this\nintroduces an optional check before showing a repository in gitweb.\n\nI also changed the 'No such directory' error message to 'No such\nproject' because the user visiting my gitweb should not know what\ndirectories I have in the project root directory.\n\nundef $project; is used to prevent displaying the description.\n---\nPerhaps there should be another option which allows only those\nrepositories to be shown which are in $projects_list.\n---\n Makefile           |    2 ++\n gitweb/gitweb.perl |   18 ++++++++++++------\n 2 files changed, 14 insertions(+), 6 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7b3114f..63df24c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -132,6 +132,7 @@ GITWEB_HOMETEXT = indextext.html\n GITWEB_CSS = gitweb.css\n GITWEB_LOGO = git-logo.png\n GITWEB_FAVICON = git-favicon.png\n+GITWEB_EXPORT_OK =\n \n export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR\n \n@@ -637,6 +638,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \t    -e 's|++GITWEB_CSS++|$(GITWEB_CSS)|g' \\\n \t    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n+\t    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \\\n \t    $< >$@+\n \tchmod +x $@+\n \tmv $@+ $@\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d89f709..3944d13 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -54,6 +54,9 @@ our $favicon = \"++GITWEB_FAVICON++\";\n # source of projects list\n our $projects_list = \"++GITWEB_LIST++\";\n \n+# show repository only if this file exists\n+our $export_ok = \"++GITWEB_EXPORT_OK++\";\n+\n # list of git base URLs used for URL to where fetch project from,\n # i.e. full URL is \"$git_base_url/$project\"\n our @git_base_url_list = (\"++GITWEB_BASE_URL++\");\n@@ -181,12 +184,13 @@ if (defined $project) {\n }\n if (defined $project) {\n \tif (!validate_input($project)) {\n+\t\tundef $project;\n \t\tdie_error(undef, \"Invalid project parameter\");\n \t}\n-\tif (!(-d \"$projectroot/$project\")) {\n-\t\tdie_error(undef, \"No such directory\");\n-\t}\n-\tif (!(-e \"$projectroot/$project/HEAD\")) {\n+\tif (!(-d \"$projectroot/$project\") ||\n+\t    !(-e \"$projectroot/$project/HEAD\") ||\n+\t    ($export_ok && !(-e \"$projectroot/$project/$export_ok\"))) {\n+\t\tundef $project;\n \t\tdie_error(undef, \"No such project\");\n \t}\n \t$git_dir = \"$projectroot/$project\";\n@@ -694,7 +698,8 @@ sub git_get_projects_list {\n \t\tmy $dir = $projects_list;\n \t\topendir my ($dh), $dir or return undef;\n \t\twhile (my $dir = readdir($dh)) {\n-\t\t\tif (-e \"$projectroot/$dir/HEAD\") {\n+\t\t\tif (-e \"$projectroot/$dir/HEAD\" && (!$export_ok ||\n+\t\t\t    -e \"$projectroot/$dir/$export_ok\")) {\n \t\t\t\tmy $pr = {\n \t\t\t\t\tpath => $dir,\n \t\t\t\t};\n@@ -716,7 +721,8 @@ sub git_get_projects_list {\n \t\t\tif (!defined $path) {\n \t\t\t\tnext;\n \t\t\t}\n-\t\t\tif (-e \"$projectroot/$path/HEAD\") {\n+\t\t\tif (-e \"$projectroot/$path/HEAD\" && (!$export_ok ||\n+\t\t\t    -e \"$projectroot/$path/$export_ok\")) {\n \t\t\t\tmy $pr = {\n \t\t\t\t\tpath => $path,\n \t\t\t\t\towner => decode(\"utf8\", $owner, Encode::FB_DEFAULT),\n-- \n1.4.2.g0ea2\n"},{"id":"27012","messageId":"eehjtn$ipm$1@sea.gmane.org","threadId":"5578","inReplyTo":"20060916192750.GA27008@moooo.ath.cx","subject":"Re: [PATCH] gitweb: export-ok option","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-16T19:40:12Z","receivedAt":"2006-09-16T19:40:12Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthias Lederhofer wrote:\n\n> Perhaps there should be another option which allows only those\n> repositories to be shown which are in $projects_list.\n\nIf $projects_list is a file (and not directory), only repositories\nspecified there are shown.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27013","messageId":"eehk5p$ipm$2@sea.gmane.org","threadId":"5578","inReplyTo":"20060916192750.GA27008@moooo.ath.cx","subject":"Re: [PATCH] gitweb: export-ok option","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-16T19:44:30Z","receivedAt":"2006-09-16T19:44:30Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Matthias Lederhofer wrote:\n\n> Similar to git-daemon checking for git-daemon-export-ok this\n> introduces an optional check before showing a repository in gitweb.\n> \n> I also changed the 'No such directory' error message to 'No such\n> project' because the user visiting my gitweb should not know what\n> directories I have in the project root directory.\n> \n> undef $project; is used to prevent displaying the description.\n> ---\n> Perhaps there should be another option which allows only those\n> repositories to be shown which are in $projects_list.\n\nI don't know what this is for (well, except replacing 'No such directory'\nerror message by 'No such project'). If you want only some of repositories\nto be present in gitweb, you simply use $projects_list _file_ (e.g. using\nnew \"project_index\" action to generate it) and edit it to contain only the\nrepositories you want to be shown in gitweb.\n\nUnless of course the person who hosts gitweb, and the person who owns\nrepository are uncommunicado, and you want the power of deciding if\nrepository is present in gitweb or not to be placed in the hands of\nrepository owner. Still, gitweb must be configured for this.\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27015","messageId":"20060916203333.GA29036@moooo.ath.cx","threadId":"5578","inReplyTo":"eehjtn$ipm$1@sea.gmane.org","subject":"Re: [PATCH] gitweb: export-ok option","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-16T20:33:33Z","receivedAt":"2006-09-16T20:33:33Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Jakub Narebski <jnareb@gmail.com> wrote:\n> Matthias Lederhofer wrote:\n> \n> > Perhaps there should be another option which allows only those\n> > repositories to be shown which are in $projects_list.\n> \n> If $projects_list is a file (and not directory), only repositories\n> specified there are shown.\n\nThe main problem is not the list of projects. Every repository below\n$project_root can be viewed using ?p=path/to/repostory.\n"},{"id":"27016","messageId":"7vy7sj8s4g.fsf@assigned-by-dhcp.cox.net","threadId":"5578","inReplyTo":"eehjtn$ipm$1@sea.gmane.org","subject":"Re: [PATCH] gitweb: export-ok option","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-16T20:37:51Z","receivedAt":"2006-09-16T20:37:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Matthias Lederhofer wrote:\n>\n>> Perhaps there should be another option which allows only those\n>> repositories to be shown which are in $projects_list.\n>\n> If $projects_list is a file (and not directory), only repositories\n> specified there are shown.\n\nIf you can _guess_ project's name, you can go directly to\ngit_summary with it, and the page (or links that the page leads\nto) does not check $projects_list at all, no?\n\nI think Matthias's patch addresses that issue.\n"},{"id":"27020","messageId":"20060916214323.GA21637@moooo.ath.cx","threadId":"5578","inReplyTo":"20060916192750.GA27008@moooo.ath.cx","subject":"[PATCH] gitweb: option 'strict export'","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-16T21:43:23Z","receivedAt":"2006-09-16T21:43:23Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"With this option enabled gitweb will only give access to repositories\nwhich are also shown on the overview page.\n---\nMatthias Lederhofer <matled@gmx.net> wrote:\n> Perhaps there should be another option which allows only those\n> repositories to be shown which are in $projects_list.\nHere it is.  This option is probably the one more likely to be used.\nIt disallows access to repositories (using ?p=path/to/repository) that\nare not on the projects-list-page.\n---\n Makefile           |    2 ++\n gitweb/gitweb.perl |   12 +++++++++++-\n 2 files changed, 13 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 63df24c..0e17d4c 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -133,6 +133,7 @@ GITWEB_CSS = gitweb.css\n GITWEB_LOGO = git-logo.png\n GITWEB_FAVICON = git-favicon.png\n GITWEB_EXPORT_OK =\n+GITWEB_STRICT_EXPORT =\n \n export prefix bindir gitexecdir template_dir GIT_PYTHON_DIR\n \n@@ -639,6 +640,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \t    -e 's|++GITWEB_LOGO++|$(GITWEB_LOGO)|g' \\\n \t    -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \\\n \t    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \\\n+\t    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \\\n \t    $< >$@+\n \tchmod +x $@+\n \tmv $@+ $@\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 3944d13..976f7ec 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -57,6 +57,9 @@ our $projects_list = \"++GITWEB_LIST++\";\n # show repository only if this file exists\n our $export_ok = \"++GITWEB_EXPORT_OK++\";\n \n+# only allow viewing of repositories also shown on the overview page\n+our $strict_export = \"++GITWEB_STRICT_EXPORT++\";\n+\n # list of git base URLs used for URL to where fetch project from,\n # i.e. full URL is \"$git_base_url/$project\"\n our @git_base_url_list = (\"++GITWEB_BASE_URL++\");\n@@ -189,7 +192,8 @@ if (defined $project) {\n \t}\n \tif (!(-d \"$projectroot/$project\") ||\n \t    !(-e \"$projectroot/$project/HEAD\") ||\n-\t    ($export_ok && !(-e \"$projectroot/$project/$export_ok\"))) {\n+\t    ($export_ok && !(-e \"$projectroot/$project/$export_ok\")) ||\n+\t    ($strict_export && !project_in_list($project))) {\n \t\tundef $project;\n \t\tdie_error(undef, \"No such project\");\n \t}\n@@ -384,6 +388,12 @@ sub untabify {\n \treturn $line;\n }\n \n+sub project_in_list {\n+\tmy $project = shift;\n+\tmy @list = git_get_projects_list();\n+\treturn(@list && scalar(grep { $_->{'path'} eq $project } @list) != 0);\n+}\n+\n ## ----------------------------------------------------------------------\n ## HTML aware string manipulation\n \n-- \n1.4.2.g0ea2\n"},{"id":"27023","messageId":"20060916223027.GA32679@moooo.ath.cx","threadId":"5578","inReplyTo":"20060916192750.GA27008@moooo.ath.cx","subject":"[PATCH/current master] gitweb: do not use 'No such directory' error message","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-16T22:30:27Z","receivedAt":"2006-09-16T22:30:27Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"undef $project; to prevent a file named description to be read.\n---\nSorry, I patched an old version.  Here is the patch for the current\nmaster/next.\n---\n gitweb/gitweb.perl |   11 ++++-------\n 1 files changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex a81c8d4..07ea1ea 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -203,13 +203,10 @@ if (defined $project) {\n \t$project = undef unless $project;\n }\n if (defined $project) {\n-\tif (!validate_input($project)) {\n-\t\tdie_error(undef, \"Invalid project parameter\");\n-\t}\n-\tif (!(-d \"$projectroot/$project\")) {\n-\t\tdie_error(undef, \"No such directory\");\n-\t}\n-\tif (!(-e \"$projectroot/$project/HEAD\")) {\n+\tif (!validate_input($project) ||\n+\t    !(-d \"$projectroot/$project\") ||\n+\t    !(-e \"$projectroot/$project/HEAD\")) {\n+\t\tundef $project;\n \t\tdie_error(undef, \"No such project\");\n \t}\n \t$git_dir = \"$projectroot/$project\";\n-- \n1.4.2.g0ea2\n"},{"id":"27024","messageId":"20060916223101.GB32679@moooo.ath.cx","threadId":"5578","inReplyTo":"20060916223027.GA32679@moooo.ath.cx","subject":"[PATCH] gitweb: export options","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-16T22:31:01Z","receivedAt":"2006-09-16T22:31:01Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"$export_ok: If this variable evaluates to true it is checked\nif a file with this name exists in the repository.  If it\ndoes not exist the repository cannot be viewed from gitweb.\n(Similar to git-daemon-export-ok for git-daemon).\n\n$strict_export: If this variable evaluates to true only\nrepositories listed on the project-list-page of gitweb can\nbe accessed.\n---\n Makefile           |    4 ++++\n gitweb/gitweb.perl |   23 ++++++++++++++++++++---\n 2 files changed, 24 insertions(+), 3 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex 7b3114f..b9938ac 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -126,6 +126,8 @@ GITWEB_CONFIG = gitweb_config.perl\n GITWEB_HOME_LINK_STR = projects\n GITWEB_SITENAME =\n GITWEB_PROJECTROOT = /pub/git\n+GITWEB_EXPORT_OK =\n+GITWEB_STRICT_EXPORT =\n GITWEB_BASE_URL =\n GITWEB_LIST =\n GITWEB_HOMETEXT = indextext.html\n@@ -631,6 +633,8 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl\n \t    -e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \\\n \t    -e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \\\n \t    -e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \\\n+\t    -e 's|++GITWEB_EXPORT_OK++|$(GITWEB_EXPORT_OK)|g' \\\n+\t    -e 's|++GITWEB_STRICT_EXPORT++|$(GITWEB_STRICT_EXPORT)|g' \\\n \t    -e 's|++GITWEB_BASE_URL++|$(GITWEB_BASE_URL)|g' \\\n \t    -e 's|++GITWEB_LIST++|$(GITWEB_LIST)|g' \\\n \t    -e 's|++GITWEB_HOMETEXT++|$(GITWEB_HOMETEXT)|g' \\\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 07ea1ea..2a63c17 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -54,6 +54,13 @@ our $favicon = \"++GITWEB_FAVICON++\";\n # source of projects list\n our $projects_list = \"++GITWEB_LIST++\";\n \n+# show repository only if this file exists\n+# (only effective if this variable evaluates to true)\n+our $export_ok = \"++GITWEB_EXPORT_OK++\";\n+\n+# only allow viewing of repositories also shown on the overview page\n+our $strict_export = \"++GITWEB_STRICT_EXPORT++\";\n+\n # list of git base URLs used for URL to where fetch project from,\n # i.e. full URL is \"$git_base_url/$project\"\n our @git_base_url_list = (\"++GITWEB_BASE_URL++\");\n@@ -205,7 +212,9 @@ if (defined $project) {\n if (defined $project) {\n \tif (!validate_input($project) ||\n \t    !(-d \"$projectroot/$project\") ||\n-\t    !(-e \"$projectroot/$project/HEAD\")) {\n+\t    !(-e \"$projectroot/$project/HEAD\") ||\n+\t    ($export_ok && !(-e \"$projectroot/$project/$export_ok\")) ||\n+\t    ($strict_export && !project_in_list($project))) {\n \t\tundef $project;\n \t\tdie_error(undef, \"No such project\");\n \t}\n@@ -402,6 +411,12 @@ sub untabify {\n \treturn $line;\n }\n \n+sub project_in_list {\n+\tmy $project = shift;\n+\tmy @list = git_get_projects_list();\n+\treturn @list && scalar(grep { $_->{'path'} eq $project } @list);\n+}\n+\n ## ----------------------------------------------------------------------\n ## HTML aware string manipulation\n \n@@ -714,7 +729,8 @@ sub git_get_projects_list {\n \n \t\t\t\tmy $subdir = substr($File::Find::name, $pfxlen + 1);\n \t\t\t\t# we check related file in $projectroot\n-\t\t\t\tif (-e \"$projectroot/$subdir/HEAD\") {\n+\t\t\t\tif (-e \"$projectroot/$subdir/HEAD\" && (!$export_ok ||\n+\t\t\t\t    -e \"$projectroot/$subdir/$export_ok\")) {\n \t\t\t\t\tpush @list, { path => $subdir };\n \t\t\t\t\t$File::Find::prune = 1;\n \t\t\t\t}\n@@ -735,7 +751,8 @@ sub git_get_projects_list {\n \t\t\tif (!defined $path) {\n \t\t\t\tnext;\n \t\t\t}\n-\t\t\tif (-e \"$projectroot/$path/HEAD\") {\n+\t\t\tif (-e \"$projectroot/$path/HEAD\" && (!$export_ok ||\n+\t\t\t    -e \"$projectroot/$path/$export_ok\")) {\n \t\t\t\tmy $pr = {\n \t\t\t\t\tpath => $path,\n \t\t\t\t\towner => decode(\"utf8\", $owner, Encode::FB_DEFAULT),\n-- \n1.4.2.g0ea2\n"},{"id":"27052","messageId":"7v64fm7u2q.fsf@assigned-by-dhcp.cox.net","threadId":"5578","inReplyTo":"20060916223101.GB32679@moooo.ath.cx","subject":"Re: [PATCH] gitweb: export options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T08:53:17Z","receivedAt":"2006-09-17T08:53:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> $export_ok: If this variable evaluates to true it is checked\n> if a file with this name exists in the repository.  If it\n> does not exist the repository cannot be viewed from gitweb.\n> (Similar to git-daemon-export-ok for git-daemon).\n>\n> $strict_export: If this variable evaluates to true only\n> repositories listed on the project-list-page of gitweb can\n> be accessed.\n\nIs this replacement for your earlier two patches?\n\n        [PATCH] gitweb: export-ok option\n        [PATCH] gitweb: option 'strict export'\n\nWhat's the difference between this and the previous two?\n\nI am asking this question because I am lazy and do not want to\nreview two sets of similar patches ;-).\n"},{"id":"27056","messageId":"20060917090710.GA18153@moooo.ath.cx","threadId":"5578","inReplyTo":"7v64fm7u2q.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: export options","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-17T09:07:10Z","receivedAt":"2006-09-17T09:07:10Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"Junio C Hamano <junkio@cox.net> wrote:\n> Matthias Lederhofer <matled@gmx.net> writes:\n> Is this replacement for your earlier two patches?\nYes, it is, they did not apply on the current master. (I fetched the\nnew heads, had a short look at the log but forgot to update my working\nheads :) ).\n\n>         [PATCH] gitweb: export-ok option\n>         [PATCH] gitweb: option 'strict export'\n> \n> What's the difference between this and the previous two?\nNow I decided to split it in another way: first remove the\nno-such-directory error and then implement the two new features. The\npatches should be equivalent to those before.\n"},{"id":"27066","messageId":"7vodte4w9w.fsf@assigned-by-dhcp.cox.net","threadId":"5578","inReplyTo":"20060917090710.GA18153@moooo.ath.cx","subject":"Re: [PATCH] gitweb: export options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T10:34:03Z","receivedAt":"2006-09-17T10:34:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> Junio C Hamano <junkio@cox.net> wrote:\n>> Matthias Lederhofer <matled@gmx.net> writes:\n>> Is this replacement for your earlier two patches?\n> Yes, it is, they did not apply on the current master. (I fetched the\n> new heads, had a short look at the log but forgot to update my working\n> heads :) ).\n>\n>>         [PATCH] gitweb: export-ok option\n>>         [PATCH] gitweb: option 'strict export'\n>> \n>> What's the difference between this and the previous two?\n>\n> Now I decided to split it in another way: first remove the\n> no-such-directory error and then implement the two new features. The\n> patches should be equivalent to those before.\n\nI see.\n\nThe PATHINFO stuff Martin Waitz did mucks with $project somewhat\nlater than this part of the patch, possibly bypassing your\nchecks.  Could you check what's in 'master' to see if it is\nreasonable and if not fix it up please?\n"},{"id":"27076","messageId":"20060917132948.GA976@moooo.ath.cx","threadId":"5578","inReplyTo":"7vodte4w9w.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export","fromName":"Matthias Lederhofer","fromEmail":"matled@gmx.net","sentAt":"2006-09-17T13:29:48Z","receivedAt":"2006-09-17T13:29:48Z","isPatch":true,"sender":{"key":"matled@gmx.net","avatar":null},"body":"---\nJunio C Hamano <junkio@cox.net> wrote:\n> Matthias Lederhofer <matled@gmx.net> writes:\n> The PATHINFO stuff Martin Waitz did mucks with $project somewhat\n> later than this part of the patch, possibly bypassing your\n> checks.  Could you check what's in 'master' to see if it is\n> reasonable and if not fix it up please?\nThis patch replaces the other two warning fixes by Jakub and me.  I've\nput the whole thing in a sub-routine to keep the indentation level\nlow.\n---\n gitweb/gitweb.perl |   34 +++++++++++++++++++++-------------\n 1 files changed, 21 insertions(+), 13 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 497129a..0fb8638 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -189,9 +189,6 @@ do $GITWEB_CONFIG if -e $GITWEB_CONFIG;\n # version of the core git binary\n our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : \"unknown\";\n \n-# path to the current git repository\n-our $git_dir;\n-\n $projects_list ||= $projectroot;\n \n # ======================================================================\n@@ -273,30 +270,41 @@ if (defined $searchtext) {\n }\n \n # now read PATH_INFO and use it as alternative to parameters\n-our $path_info = $ENV{\"PATH_INFO\"};\n-$path_info =~ s|^/||;\n-$path_info =~ s|/$||;\n-if (validate_input($path_info) && !defined $project) {\n+sub evaluate_path_info {\n+\treturn if defined $project;\n+\tmy $path_info = $ENV{\"PATH_INFO\"};\n+\treturn if !$path_info;\n+\t$path_info =~ s,(^/|/$),,gs;\n+\t$path_info = validate_input($path_info);\n+\treturn if !$path_info;\n \t$project = $path_info;\n \twhile ($project && !-e \"$projectroot/$project/HEAD\") {\n \t\t$project =~ s,/*[^/]*$,,;\n \t}\n-\tif (defined $project) {\n-\t\t$project = undef unless $project;\n+\tif (!$project ||\n+\t    ($export_ok && !-e \"$projectroot/$project/$export_ok\") ||\n+\t    ($strict_export && !project_in_list($project))) {\n+\t\tundef $project;\n+\t\treturn;\n \t}\n+\t# do not change any parameters if an action is given using the query string\n+\treturn if $action;\n \tif ($path_info =~ m,^$project/([^/]+)/(.+)$,) {\n \t\t# we got \"project.git/branch/filename\"\n \t\t$action    ||= \"blob_plain\";\n-\t\t$hash_base ||= $1;\n-\t\t$file_name ||= $2;\n+\t\t$hash_base ||= validate_input($1);\n+\t\t$file_name ||= validate_input($2);\n \t} elsif ($path_info =~ m,^$project/([^/]+)$,) {\n \t\t# we got \"project.git/branch\"\n \t\t$action ||= \"shortlog\";\n-\t\t$hash   ||= $1;\n+\t\t$hash   ||= validate_input($1);\n \t}\n }\n+evaluate_path_info();\n \n-$git_dir = \"$projectroot/$project\";\n+# path to the current git repository\n+our $git_dir;\n+$git_dir = \"$projectroot/$project\" if $project;\n \n # dispatch\n my %actions = (\n-- \n1.4.2.1.ge767\n"},{"id":"27094","messageId":"7v4pv62lni.fsf@assigned-by-dhcp.cox.net","threadId":"5578","inReplyTo":"20060917132948.GA976@moooo.ath.cx","subject":"Re: [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T22:06:25Z","receivedAt":"2006-09-17T22:06:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthias Lederhofer <matled@gmx.net> writes:\n\n> This patch replaces the other two warning fixes by Jakub and me.  I've\n> put the whole thing in a sub-routine to keep the indentation level\n> low.\n\nLooks much cleaner with this extra sub.\n\nThis does not seem have the \"colon as a cue that the URL is also\ntalking about a branch\", Jakub's summary of the discussion\nbetween you two on #git channel.  I think that proposal makes\nsense as well.\n"},{"id":"27095","messageId":"eekj5b$rlc$1@sea.gmane.org","threadId":"5578","inReplyTo":"7v4pv62lni.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-09-17T22:45:44Z","receivedAt":"2006-09-17T22:45:44Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Matthias Lederhofer <matled@gmx.net> writes:\n> \n>> This patch replaces the other two warning fixes by Jakub and me.  I've\n>> put the whole thing in a sub-routine to keep the indentation level\n>> low.\n> \n> Looks much cleaner with this extra sub.\n> \n> This does not seem have the \"colon as a cue that the URL is also\n> talking about a branch\", Jakub's summary of the discussion\n> between you two on #git channel.  I think that proposal makes\n> sense as well.\n\nWell, that is because this patch _predates_ the discussion \n(and proposal/conclusions). \n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"27096","messageId":"7vzmcy143n.fsf@assigned-by-dhcp.cox.net","threadId":"5578","inReplyTo":"eekj5b$rlc$1@sea.gmane.org","subject":"Re: [PATCH] gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-09-17T23:10:52Z","receivedAt":"2006-09-17T23:10:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>> Matthias Lederhofer <matled@gmx.net> writes:\n>> \n>>> This patch replaces the other two warning fixes by Jakub and me.  I've\n>>> put the whole thing in a sub-routine to keep the indentation level\n>>> low.\n>> \n>> Looks much cleaner with this extra sub.\n>> \n>> This does not seem have the \"colon as a cue that the URL is also\n>> talking about a branch\", Jakub's summary of the discussion\n>> between you two on #git channel.  I think that proposal makes\n>> sense as well.\n>\n> Well, that is because this patch _predates_ the discussion \n> (and proposal/conclusions). \n\nYup, I know, I was not complaining.\n\nI was saying that I do not oppose to a follow-up patch to add\nthat \"colon\" stuff.\n"}]}