Re: [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 9, 2023, 23:05 UTC
- Message-ID
- <xmqqfsbel9sf.fsf@gitster.g>
- In-Reply-To
- <20230209222648.z-sqdvWiK7xa-NLagt3B_X_4bFQJBsA8cA06YvgXqWQ@z>
Daniel Abrecht <git-git@nodmarc.danielabrecht.ch> writes:
Show 21 quoted lines
> 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@danielabrecht.ch>
> ---
> 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?
Show 5 quoted lines
> + $base_url .= '/' if not $base_url =~ /\/$/; > + > # target of the home link on top of all pages > our $home_link = $my_uri || "/"; > }