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

Re: gitweb bug: broken "next" and other links

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 12, 2008, 11:39 UTC
Message-ID
<200802121239.06287.jnareb@gmail.com>
In-Reply-To
<200802111630.29159.jnareb@gmail.com>
On Mon, 11 Feb 2008, Jakub Narebski wrote:
Show 21 quoted lines
> I'm sorry. You are right. I haven't seen breakage because it shows
> only when you use 'pathinfo' feature and pathinfo URLs.
> 
> Below there is a fix for that; actully only second part mentioned
> (and first in patch) is needed, i.e. moving setting $params{'project'}
> before dealing with -replay is needed I think to fix this bug.
> 
> Could you test it please?
> -->8 --
> From: Jakub Narebski <jnareb@gmail.com>
> Subject: [PATCH] gitweb: Fix bug in href(..., -replay=>1) when 'pathinfo' feature used
> 
> URLs generated by href(..., -replay=>1) (which includes 'next page'
> links and alternate view links) were not created correctly when using
> 'pathinfo' feature (i.e. using pathinfo instead of query string to
> denote project / git repository used).
> 
> This resulted in broken links such like:
>   http://www.example.com/w/ARRAY(0x85a5318)?a=shortlog;pg=1
> instead of:
>   http://www.example.com/w/project.git?a=shortlog;pg=1
Actually the error is there even without using 'pathinfo' feature,
namely if you use pathinfo to provide project, for example:
  http://www.example.com/w/project.git?a=shortlog
then 'next' link on the page lacks project (instead of having
dereferenced anonymous array reference, i.e. ARRAY(sth)), like below
  http://www.example.com/w/?a=shortlog;pg=1

But I could not come up with automated test which would _fail_ on this error. So please check, and reply if this patch helps.

Below there is hand-crafted minimal fixing patch.
Show 28 quoted lines
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 5e88637..648ee13 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -611,17 +611,17 @@ sub href(%) {
>  	);
>  	my %mapping = @mapping;
>  
> +	$params{'project'} = $project unless exists $params{'project'};
> +
>  	if ($params{-replay}) {
>  		while (my ($name, $symbol) = each %mapping) {
>  			if (!exists $params{$name}) {
>  				# to allow for multivalued params we use arrayref form
>  				$params{$name} = [ $cgi->param($symbol) ];
>  			}
>  		}
>  	}
>  
> -	$params{'project'} = $project unless exists $params{'project'};
> -
>  	my ($use_pathinfo) = gitweb_check_feature('pathinfo');
>  	if ($use_pathinfo) {
>  		# use PATH_INFO for project name
> -- 
> 1.5.4
> 
> 
-- 
Jakub Narebski
Poland
Previous: Jakub NarebskiNext: Jakub Narebski
Message 5 of 16 in “gitweb bug: broken "next" and other links”
  1. Wincent ColaiutaFeb 11, 2008
  2. Jakub NarebskiFeb 11, 2008
  3. Wincent ColaiutaFeb 11, 2008
  4. Jakub NarebskiFeb 11, 2008
  5. Jakub NarebskiFeb 12, 2008
  6. Jakub NarebskiFeb 12, 2008
  7. Wincent ColaiutaFeb 12, 2008
  8. Jakub NarebskiFeb 12, 2008
  9. Wincent ColaiutaFeb 12, 2008
  10. Jakub NarebskiFeb 15, 2008
  11. Wincent ColaiutaFeb 17, 2008
  12. Junio C HamanoFeb 17, 2008
  13. Jakub NarebskiFeb 18, 2008
  14. Junio C HamanoFeb 18, 2008
  15. Jakub NarebskiFeb 19, 2008
  16. Wincent ColaiutaFeb 19, 2008

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.