Re: [RFD] gitweb: href() function to generate URLs for CGI
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Aug 22, 2006, 09:34 UTC
- Message-ID
- <ecej3m$rv2$3@sea.gmane.org>
- In-Reply-To
- <7vodudno88.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 10 quoted lines
> So the last part of the above should perhaps read:
>
> my @result = ();
> for (my $i = 0; $i < @mapping; $i += 2) {
> my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
> if (defined $params{$name}) {
> push @result, join('=', esc_param($symbol),
> esc_param($params{$name}));
> }
> }There is really no need to escape $symbol; we control this, and it is CGI param safe.
BTW. why use join? The following
push @result, "$symbol=" . esc_param($params{$name}); would be simplier... we could even use
$href .= ($i > 0? ";" : "") . "$symbol=" . esc_param($params{$name});although probably this isn't best idea (worse readibility).
-- Jakub Narebski Warsaw, Poland ShadeHawk on #git