List for cgit developers and users
 help / color / mirror / Atom feed
From: john at keeping.me.uk (John Keeping)
Subject: Slash after /about
Date: Wed, 30 Jan 2019 18:37:33 +0000	[thread overview]
Message-ID: <20190130182703.GA16704@john.keeping.me.uk> (raw)
In-Reply-To: <b0bbc1d078f60c1bf0160d95a8f863946c574b0f.camel@aegee.org>

On Tue, Jan 29, 2019 at 09:21:01AM +0000, dilyan.palauzov at aegee.org wrote:
> For CGI I use thttpd and it tends to remove terminating slashes in the requests.
> 
> cgit wants to have slash after about/ .
> 
> So they do not work together, endless loop happens.  Proposed fix:
> 
> diff --git a/cmd.c b/cmd.c
> --- a/cmd.c
> +++ b/cmd.c
> @@ -40,16 +40,7 @@ static void atom_fn(void)
>  static void about_fn(void)
>  {
>         if (ctx.repo) {
> -               size_t path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0;
> -               if (!ctx.qry.path &&
> -                   ctx.qry.url[strlen(ctx.qry.url) - 1] != '/' &&
> -                   (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) {
> -                       char *currenturl = cgit_currenturl();
> -                       char *redirect = fmtalloc("%s/", currenturl);
> -                       cgit_redirect(redirect, true);
> -                       free(currenturl);
> -                       free(redirect);
> -               } else if (ctx.repo->readme.nr)
> +               if (ctx.repo->readme.nr)
>                         cgit_print_repo_readme(ctx.qry.path);
>                 else if (ctx.repo->homepage)
>                         cgit_redirect(ctx.repo->homepage, false);

According to commit d703480 ("about: always ensure page has a trailing
slash") the trailing slash is required for easy embedding of links to
other /about/ pages.

I suspect it's possible to append the trailing slash without going round
a redirect loop, but I don't think this patch will work.

(I'm also inclined to agree that thttpd is broken here and should pass
the URL to CGI scripts as it is received.)


      parent reply	other threads:[~2019-01-30 18:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29  9:21 
2019-01-29 18:58 ` 
2019-01-30 17:53   ` Dilyan.Palauzov
2019-01-30 18:37 ` john [this message]

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=20190130182703.GA16704@john.keeping.me.uk \
    --to=cgit@lists.zx2c4.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).