* [PATCHv2] gitweb: Git config keys are case insensitive, make config search too @ 2011-07-27 20:53 Jakub Narebski 2011-07-28 20:14 ` Junio C Hamano 0 siblings, 1 reply; 3+ messages in thread From: Jakub Narebski @ 2011-07-27 20:53 UTC (permalink / raw) To: git "git config -z -l" that gitweb uses in git_parse_project_config() to populate %config hash returns section and key names of config variables in lowercase (they are case insensitive). When checking %config in git_get_project_config() we have to take it into account. Gitweb does not (yet?) use git config variables with subsection, so we can simply lowercase $key in git_get_project_config (only subsection names are case sensitive). Signed-off-by: Jakub Narebski <jnareb@gmail.com> --- I think it is a resend, but I haven't found first version. The patch is unchanged, but commit message got improved. It is not as much bugfix as hardening (against user e.g. adding new overridable feature via gitweb config file). gitweb/gitweb.perl | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1070805..90b5a73 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2526,6 +2526,7 @@ sub git_get_project_config { # key sanity check return unless ($key); + $key = lc($key); # assuming there is no subsection $key =~ s/^gitweb\.//; return if ($key =~ m/\W/); ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCHv2] gitweb: Git config keys are case insensitive, make config search too 2011-07-27 20:53 [PATCHv2] gitweb: Git config keys are case insensitive, make config search too Jakub Narebski @ 2011-07-28 20:14 ` Junio C Hamano 2011-07-28 21:38 ` [PATCHv3] " Jakub Narebski 0 siblings, 1 reply; 3+ messages in thread From: Junio C Hamano @ 2011-07-28 20:14 UTC (permalink / raw) To: Jakub Narebski; +Cc: git Jakub Narebski <jnareb@gmail.com> writes: > "git config -z -l" that gitweb uses in git_parse_project_config() to > populate %config hash returns section and key names of config > variables in lowercase (they are case insensitive). When checking > %config in git_get_project_config() we have to take it into account. > > Gitweb does not (yet?) use git config variables with subsection, so we > can simply lowercase $key in git_get_project_config (only subsection > names are case sensitive). Why stop there, I have to wonder, instead of futureproofing with minimum cost, even with something naïve like: if (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\.(.*)\.(.*)$)) { $key = join(".", lc($hi), $mi, lc($lo); } else { $key = lc($key); } > Signed-off-by: Jakub Narebski <jnareb@gmail.com> > --- > I think it is a resend, but I haven't found first version. > > The patch is unchanged, but commit message got improved. > It is not as much bugfix as hardening (against user e.g. adding > new overridable feature via gitweb config file). > > gitweb/gitweb.perl | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl > index 1070805..90b5a73 100755 > --- a/gitweb/gitweb.perl > +++ b/gitweb/gitweb.perl > @@ -2526,6 +2526,7 @@ sub git_get_project_config { > > # key sanity check > return unless ($key); > + $key = lc($key); # assuming there is no subsection > $key =~ s/^gitweb\.//; > return if ($key =~ m/\W/); > ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCHv3] gitweb: Git config keys are case insensitive, make config search too 2011-07-28 20:14 ` Junio C Hamano @ 2011-07-28 21:38 ` Jakub Narebski 0 siblings, 0 replies; 3+ messages in thread From: Jakub Narebski @ 2011-07-28 21:38 UTC (permalink / raw) To: Junio C Hamano; +Cc: git "git config -z -l" that gitweb uses in git_parse_project_config() to populate %config hash returns section and key names of config variables in lowercase (they are case insensitive). When checking %config in git_get_project_config() we have to take it into account. Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jakub Narebski <jnareb@gmail.com> --- On Thu, 28 Jul 2011, Junio C Hamano napisał: > Jakub Narebski <jnareb@gmail.com> writes: > > > "git config -z -l" that gitweb uses in git_parse_project_config() to > > populate %config hash returns section and key names of config > > variables in lowercase (they are case insensitive). When checking > > %config in git_get_project_config() we have to take it into account. > > > > Gitweb does not (yet?) use git config variables with subsection, so we > > can simply lowercase $key in git_get_project_config (only subsection > > names are case sensitive). > > Why stop there, I have to wonder, instead of futureproofing with minimum > cost, even with something naïve like: > > if (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\.(.*)\.(.*)$)) { > $key = join(".", lc($hi), $mi, lc($lo); > } else { > $key = lc($key); > } Well, I thought it would be more involved than this. Anyway, here it is: gitweb/gitweb.perl | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1070805..f858d1b 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -2526,6 +2526,13 @@ sub git_get_project_config { # key sanity check return unless ($key); + # only subsection, if exists, is case sensitive, + # and not lowercased by 'git config -z -l' + if (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\.(.*)\.([^.]*)$/)) { + $key = join(".", lc($hi), $mi, lc($lo)); + } else { + $key = lc($key); + } $key =~ s/^gitweb\.//; return if ($key =~ m/\W/); -- 1.7.5 ^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-07-28 21:38 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-07-27 20:53 [PATCHv2] gitweb: Git config keys are case insensitive, make config search too Jakub Narebski 2011-07-28 20:14 ` Junio C Hamano 2011-07-28 21:38 ` [PATCHv3] " Jakub Narebski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).