Re: [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Abrecht <git-git@xxxxxxxxxxxxxxxxxxxxxxxx> writes:

> In HTML, if there is a base tag like `<base href="/a/b">`, a relative
> URL like
> `c/d` will be resolved by the browser as `a/c/d` and not as
> `a/b/c/d`. But with
> a base tag like `<base href="/a/b/">` it will result in `a/b/c/d`.
>
> Signed-off-by: Daniel Abrecht <public@xxxxxxxxxxxxxxxx>
> ---
>  gitweb/gitweb.perl | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index e66eb3d9ba..edcee1652c 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -74,6 +74,11 @@ sub evaluate_uri {
>  		}
>  	}
>
> +	# $base_url is later used in the <base> tag as a URL, if it
> doesn't end in a /

It seems an overlog line was wrapped around and broke the patch.

> +	# the browser will strip away the last component for relative URLs.
> +	# Add the / if it's missing.

The above is not an incorrect statement per-se, but if $base were
pointing at the document, we would likely break if we add an extra
slash.  Don't we want to say something like 

	# $base_url at this point points at a directory, not a
        # single document, and later is used in the <base> tag.
        # Make sure it ends in a '/'.  Otherwise, we'd lose the last
        # component when forming a relative URL.

perhaps?

> +	$base_url .= '/' if not $base_url =~ /\/$/;
> +
>  	# target of the home link on top of all pages
>  	our $home_link = $my_uri || "/";
>  }



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux