{"thread":{"id":"16960","subject":"[PATCH] gitweb: don't use pathinfo for global actions","startedAt":"2009-01-02T11:34:40Z","lastAt":"2009-01-07T21:32:16Z","messageCount":4,"participants":["Giuseppe Bilotta","Jakub Narebski","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"99161","messageId":"1230896080-22801-1-git-send-email-giuseppe.bilotta@gmail.com","threadId":"16960","inReplyTo":null,"subject":"[PATCH] gitweb: don't use pathinfo for global actions","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-02T11:34:40Z","receivedAt":"2009-01-02T11:34:40Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"With PATH_INFO urls, actions for the projects list (e.g. opml,\nproject_index) were being put in the URL right after the base. The\nresulting URL is not properly parsed by gitweb itself, since it expects\na project name as first component of the URL.\n\nAccepting global actions in use_pathinfo is not a very robust solution\ndue to possible present and future conflicts between project names and\nglobal actions, therefore we just refuse to create PATH_INFO URLs when\nthe project is not defined.\n\nSigned-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n---\n gitweb/gitweb.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 99f71b4..fa7d8ad 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -830,7 +830,7 @@ sub href (%) {\n \t}\n \n \tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n-\tif ($use_pathinfo) {\n+\tif ($use_pathinfo and defined $params{'project'}) {\n \t\t# try to put as many parameters as possible in PATH_INFO:\n \t\t#   - project name\n \t\t#   - action\n@@ -845,7 +845,7 @@ sub href (%) {\n \t\t$href =~ s,/$,,;\n \n \t\t# Then add the project name, if present\n-\t\t$href .= \"/\".esc_url($params{'project'}) if defined $params{'project'};\n+\t\t$href .= \"/\".esc_url($params{'project'});\n \t\tdelete $params{'project'};\n \n \t\t# since we destructively absorb parameters, we keep this\n-- \n1.5.6.5\n"},{"id":"99487","messageId":"200901061837.23637.jnareb@gmail.com","threadId":"16960","inReplyTo":"1230896080-22801-1-git-send-email-giuseppe.bilotta@gmail.com","subject":"Re: [PATCH] gitweb: don't use pathinfo for global actions","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-01-06T17:37:22Z","receivedAt":"2009-01-06T17:37:22Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Fri, 2 Jan 2009, Giuseppe Bilotta wrote:\n\n> With PATH_INFO urls, actions for the projects list (e.g. opml,\n> project_index) were being put in the URL right after the base. The\n> resulting URL is not properly parsed by gitweb itself, since it expects\n> a project name as first component of the URL.\n\nTherefore it really needs to be in, as df63fb also by Giuseppe\n(gitweb: use href() when generating URLs in OPML) is already in,\nand I think gitweb would generate broken OPML and TXT links without\nthis patch.\n\n> \n> Accepting global actions in use_pathinfo is not a very robust solution\n> due to possible present and future conflicts between project names and\n> global actions, therefore we just refuse to create PATH_INFO URLs when\n> the project is not defined.\n\nI think it is quite robust solution and it makes sense; we use\nshortcuts http://git.example.com for projects_list page, and\nhttp://git.example.com/path/to/repo.git for overview 'summary'\naction for a project, therefore pathinfo has to look like the\nfollowing: http://git.example.com/repo/action/hash with \"action\"\n_after_ \"project\".  And there is also matter of backward compatibility\nof URL (URLs shouldn't break).\n\nAnyway, we have $home_link for default project_list page, which\nis path_info without project, and query without query string...\n\n> \n> Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n> ---\n>  gitweb/gitweb.perl |    4 ++--\n>  1 files changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 99f71b4..fa7d8ad 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -830,7 +830,7 @@ sub href (%) {\n>  \t}\n>  \n>  \tmy $use_pathinfo = gitweb_check_feature('pathinfo');\n> -\tif ($use_pathinfo) {\n> +\tif ($use_pathinfo and defined $params{'project'}) {\n>  \t\t# try to put as many parameters as possible in PATH_INFO:\n>  \t\t#   - project name\n>  \t\t#   - action\n> @@ -845,7 +845,7 @@ sub href (%) {\n>  \t\t$href =~ s,/$,,;\n>  \n>  \t\t# Then add the project name, if present\n> -\t\t$href .= \"/\".esc_url($params{'project'}) if defined $params{'project'};\n> +\t\t$href .= \"/\".esc_url($params{'project'});\n>  \t\tdelete $params{'project'};\n>  \n>  \t\t# since we destructively absorb parameters, we keep this\n\nNice.\n\n> -- \n> 1.5.6.5\n> \n> \n\n-- \nJakub Narebski\nPoland\n"},{"id":"99615","messageId":"7vzli295m8.fsf@gitster.siamese.dyndns.org","threadId":"16960","inReplyTo":"200901061837.23637.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: don't use pathinfo for global actions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-07T21:19:11Z","receivedAt":"2009-01-07T21:19:11Z","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> Therefore it really needs to be in, as df63fb also by Giuseppe\n> (gitweb: use href() when generating URLs in OPML) is already in,\n> and I think gitweb would generate broken OPML and TXT links without\n> this patch.\n> ...\n> Acked-by: Jakub Narebski <jnareb@gmail.com>\n\nThanks for reminding me.  Queued.\n"},{"id":"99619","messageId":"cb7bb73a0901071332x1c07114cp2eefbc4490db1eb0@mail.gmail.com","threadId":"16960","inReplyTo":"200901061837.23637.jnareb@gmail.com","subject":"Re: [PATCH] gitweb: don't use pathinfo for global actions","fromName":"Giuseppe Bilotta","fromEmail":"giuseppe.bilotta@gmail.com","sentAt":"2009-01-07T21:32:16Z","receivedAt":"2009-01-07T21:32:16Z","isPatch":true,"sender":{"key":"giuseppe.bilotta@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1464?v=4"},"body":"On Tue, Jan 6, 2009 at 6:37 PM, Jakub Narebski <jnareb@gmail.com> wrote:\n> On Fri, 2 Jan 2009, Giuseppe Bilotta wrote:\n>> Accepting global actions in use_pathinfo is not a very robust solution\n>> due to possible present and future conflicts between project names and\n>> global actions, therefore we just refuse to create PATH_INFO URLs when\n>> the project is not defined.\n>\n> I think it is quite robust solution and it makes sense; we use\n> shortcuts http://git.example.com for projects_list page, and\n> http://git.example.com/path/to/repo.git for overview 'summary'\n> action for a project, therefore pathinfo has to look like the\n> following: http://git.example.com/repo/action/hash with \"action\"\n> _after_ \"project\".  And there is also matter of backward compatibility\n> of URL (URLs shouldn't break).\n>\n> Anyway, we have $home_link for default project_list page, which\n> is path_info without project, and query without query string...\n\nToday I had this idea: a possible way to have global actions into the\npath would be to use an invalid project name, but I'm not sure if\nthere ARE invalid project names at all. Maybe using something very\nabstruse such as _projects_ (underscore \"projects\" underscore) or even\njust _ (underscore).\n\nThe only thing I can think of for which global actions in path WOULD\nbe interesting would be that project tag paths would become something\nlike http://git.example.com/_/tag/sometagname which can be tagged by\nthe rel-tag microformat http://microformats.org/wiki/rel-tag ...\n\n-- \nGiuseppe \"Oblomov\" Bilotta\n"}]}