git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: continue consolidation of URL generation.

From
Junio C Hamano <junkio@cox.net>
Date
Aug 17, 2006, 01:59 UTC
Message-ID
<7voduk15sc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<11557673213372-git-send-email-tali@admingilde.org>
Martin Waitz <tali@admingilde.org> writes:
Show 23 quoted lines
> Further use href() instead of URL generation by string concatenation.
> Almost all functions are converted now.
>
> Signed-off-by: Martin Waitz <tali@admingilde.org>
> ---
>  gitweb/gitweb.perl |   68 +++++++++++++++++++++++++++-------------------------
>  1 files changed, 35 insertions(+), 33 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 37a6284..72e687e 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -204,7 +204,9 @@ sub href(%) {
>  
>  	my $href = "$my_uri?";
>  	$href .= esc_param( join(";",
> -		map { "$mapping{$_}=$params{$_}" } keys %params
> +		map {
> +			"$mapping{$_}=$params{$_}" if $params{$_}
> +		} keys %params
>  	) );
>  
>  	return $href;
This is not about "further use href()".

I think "if $params{$_}" is unsafe here. Can you guarantee that we will never want to pass 0 or an empty string as an parameter value both in the current and the future code?

I think it needs to be "if defined $params{$_}", at least.
Show 9 quoted lines
> @@ -1252,7 +1254,7 @@ sub git_difftree_body {
>  			      "<td class=\"link\">" .
>  				$cgi->a({-href => href(action=>"blob", hash=>$to_id, hash_base=>$hash, file_name=>$file)}, "blob");
>  			if ($to_id ne $from_id) { # modified
> -				print $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
> +				print " | " . $cgi->a({-href => href(action=>"blobdiff", hash=>$to_id, hash_parent=>$from_id, hash_base=>$hash, file_name=>$file)}, "diff");
>  			}
>  			print " | " . $cgi->a({-href => href(action=>"history", hash_base=>$hash, file_name=>$file)}, "history") . "\n";
>  			print "</td>\n";
Well spotted.
Previous: Jakub NarebskiNext: Martin Waitz
Message 24 of 25 in “gitweb: continue consolidation of URL generation.”
  1. gitweb: continue consolidation of URL generation.Martin Waitz, Aug 16, 2006
  2. gitweb: use common parameter parsing and generation for "o", too.Martin Waitz, Aug 16, 2006
  3. gitweb: support for "fp" parameter.Martin Waitz, Aug 16, 2006
  4. gitweb: support for / as home_link.Martin Waitz, Aug 16, 2006
  5. gitweb: fix project list if PATH_INFO=="/".Martin Waitz, Aug 16, 2006
  6. gitweb: use action dispatcher for non-project actions, too.Martin Waitz, Aug 16, 2006
  7. Junio C HamanoAug 17, 2006
  8. Carl WorthAug 17, 2006
  9. Petr BaudisAug 18, 2006
  10. Carl WorthAug 18, 2006
  11. Jakub NarebskiAug 18, 2006
  12. Petr BaudisAug 18, 2006
  13. Martin WaitzAug 17, 2006
  14. Jakub NarebskiAug 17, 2006
  15. Martin WaitzAug 17, 2006
  16. Jakub NarebskiAug 17, 2006
  17. Jakub NarebskiAug 17, 2006
  18. Martin WaitzAug 17, 2006
  19. Jakub NarebskiAug 17, 2006
  20. Martin WaitzAug 18, 2006
  21. Jakub NarebskiAug 19, 2006
  22. Martin WaitzAug 19, 2006
  23. Jakub NarebskiAug 19, 2006
  24. Junio C HamanoAug 17, 2006
  25. Martin WaitzAug 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.