{"thread":{"id":"27937","subject":"[PATCHv2] gitweb: Git config keys are case insensitive, make config search too","startedAt":"2011-07-27T20:53:33Z","lastAt":"2011-07-28T21:38:03Z","messageCount":3,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"172191","messageId":"20110727205118.10439.58875.stgit@localhost.localdomain","threadId":"27937","inReplyTo":null,"subject":"[PATCHv2] gitweb: Git config keys are case insensitive, make config search too","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-07-27T20:53:33Z","receivedAt":"2011-07-27T20:53:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"git config -z -l\" that gitweb uses in git_parse_project_config() to\npopulate %config hash returns section and key names of config\nvariables in lowercase (they are case insensitive).  When checking\n%config in git_get_project_config() we have to take it into account.\n\nGitweb does not (yet?) use git config variables with subsection, so we\ncan simply lowercase $key in git_get_project_config (only subsection\nnames are case sensitive).\n\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nI think it is a resend, but I haven't found first version.\n\nThe patch is unchanged, but commit message got improved.\nIt is not as much bugfix as hardening (against user e.g. adding\nnew overridable feature via gitweb config file).\n\n gitweb/gitweb.perl |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1070805..90b5a73 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2526,6 +2526,7 @@ sub git_get_project_config {\n \n \t# key sanity check\n \treturn unless ($key);\n+\t$key = lc($key); # assuming there is no subsection\n \t$key =~ s/^gitweb\\.//;\n \treturn if ($key =~ m/\\W/);\n \n"},{"id":"172305","messageId":"7vtya6kvrz.fsf@alter.siamese.dyndns.org","threadId":"27937","inReplyTo":"20110727205118.10439.58875.stgit@localhost.localdomain","subject":"Re: [PATCHv2] gitweb: Git config keys are case insensitive, make config search too","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-07-28T20:14:24Z","receivedAt":"2011-07-28T20:14:24Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> \"git config -z -l\" that gitweb uses in git_parse_project_config() to\n> populate %config hash returns section and key names of config\n> variables in lowercase (they are case insensitive).  When checking\n> %config in git_get_project_config() we have to take it into account.\n>\n> Gitweb does not (yet?) use git config variables with subsection, so we\n> can simply lowercase $key in git_get_project_config (only subsection\n> names are case sensitive).\n\nWhy stop there, I have to wonder, instead of futureproofing with minimum\ncost, even with something naïve like:\n\n\tif (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\\.(.*)\\.(.*)$)) {\n\t\t$key = join(\".\", lc($hi), $mi, lc($lo);\n\t} else {\n        \t$key = lc($key);\n\t}\n\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n> I think it is a resend, but I haven't found first version.\n>\n> The patch is unchanged, but commit message got improved.\n> It is not as much bugfix as hardening (against user e.g. adding\n> new overridable feature via gitweb config file).\n>\n>  gitweb/gitweb.perl |    1 +\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n>\n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index 1070805..90b5a73 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -2526,6 +2526,7 @@ sub git_get_project_config {\n>  \n>  \t# key sanity check\n>  \treturn unless ($key);\n> +\t$key = lc($key); # assuming there is no subsection\n>  \t$key =~ s/^gitweb\\.//;\n>  \treturn if ($key =~ m/\\W/);\n>  \n"},{"id":"172310","messageId":"201107282338.04954.jnareb@gmail.com","threadId":"27937","inReplyTo":"7vtya6kvrz.fsf@alter.siamese.dyndns.org","subject":"[PATCHv3] gitweb: Git config keys are case insensitive, make config search too","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-07-28T21:38:03Z","receivedAt":"2011-07-28T21:38:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"\"git config -z -l\" that gitweb uses in git_parse_project_config() to\npopulate %config hash returns section and key names of config\nvariables in lowercase (they are case insensitive).  When checking\n%config in git_get_project_config() we have to take it into account.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\nOn Thu, 28 Jul 2011, Junio C Hamano napisał:\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n> > \"git config -z -l\" that gitweb uses in git_parse_project_config() to\n> > populate %config hash returns section and key names of config\n> > variables in lowercase (they are case insensitive).  When checking\n> > %config in git_get_project_config() we have to take it into account.\n> >\n> > Gitweb does not (yet?) use git config variables with subsection, so we\n> > can simply lowercase $key in git_get_project_config (only subsection\n> > names are case sensitive).\n> \n> Why stop there, I have to wonder, instead of futureproofing with minimum\n> cost, even with something naïve like:\n> \n> \tif (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\\.(.*)\\.(.*)$)) {\n> \t\t$key = join(\".\", lc($hi), $mi, lc($lo);\n> \t} else {\n>         \t$key = lc($key);\n> \t}\n\nWell, I thought it would be more involved than this.\n\nAnyway, here it is:\n\n gitweb/gitweb.perl |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex 1070805..f858d1b 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -2526,6 +2526,13 @@ sub git_get_project_config {\n \n \t# key sanity check\n \treturn unless ($key);\n+\t# only subsection, if exists, is case sensitive,\n+\t# and not lowercased by 'git config -z -l'\n+\tif (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\\.(.*)\\.([^.]*)$/)) {\n+\t\t$key = join(\".\", lc($hi), $mi, lc($lo));\n+\t} else {\n+\t\t$key = lc($key);\n+\t}\n \t$key =~ s/^gitweb\\.//;\n \treturn if ($key =~ m/\\W/);\n \n-- \n1.7.5\n"}]}