All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Daniel Abrecht <git-git@nodmarc.danielabrecht.ch>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end
Date: Thu, 09 Feb 2023 15:05:20 -0800	[thread overview]
Message-ID: <xmqqfsbel9sf.fsf@gitster.g> (raw)
In-Reply-To: <20230209222648.z-sqdvWiK7xa-NLagt3B_X_4bFQJBsA8cA06YvgXqWQ@z> (Daniel Abrecht's message of "Thu, 09 Feb 2023 23:26:48 +0100")

Daniel Abrecht <git-git@nodmarc.danielabrecht.ch> 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@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?

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

  parent reply	other threads:[~2023-02-09 23:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 22:26 [PATCH v2] gitweb: fix base url set if PATH_INFO is used, add a / at the end Daniel Abrecht
2023-02-09 23:05 ` Junio C Hamano [this message]
2023-02-14 10:15   ` Daniel Abrecht
  -- strict thread matches above, loose matches on Subject: below --
2023-02-03 21:42 [PATCH] " Daniel Abrecht
2023-02-09 22:26 ` [PATCH v2] " Daniel Abrecht
2023-02-06 22:02 ` [PATCH] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqfsbel9sf.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git-git@nodmarc.danielabrecht.ch \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.