List for cgit developers and users
 help / color / mirror / Atom feed
From: hacking at nachtgeist.net (Daniel Reichelt)
Subject: /about redirected to /about/
Date: Thu, 13 Aug 2015 10:58:27 +0200	[thread overview]
Message-ID: <55CC5C33.4030609@nachtgeist.net> (raw)
In-Reply-To: <CAHmME9pQ0EZECbvFTLZyddp79ETkMgDVKr0KToj=FcNBscX4rQ@mail.gmail.com>

Hi Jason,

> Please let me know if this poses any problems.

I'm afraid, it does here:


Requesting a document works, however a request to /cgit/$repo.git/about/ gets
301'd to /cgit/$repo.git/about/ until firefox throws up.


I added some debug printing to cmd.c:about_pre():
----------8<----------------
static void about_pre(void)
{
fprintf(stderr, "cmd url is: #%s#\n", ctx.qry.url);
fprintf(stderr, "cmd qryp is: #%s#\n", ctx.qry.path);
        if (ctx.repo && !ctx.qry.path && ctx.qry.url[strlen(ctx.qry.url) - 1] != '/')
                cgit_redirect(fmtalloc("%s/", cgit_currenturl()), true);
}
----------8<----------------


For requesting a document, say cryptsetup.md, it writes
----------8<----------------
[Thu Aug 13 10:44:25.121565 2015] [cgi:error] [pid 1192] [client ::1:60435]
AH01215: cmd url is: #wiki.git/about#
[Thu Aug 13 10:44:25.121672 2015] [cgi:error] [pid 1192] [client ::1:60435]
AH01215: cmd qryp is: #cryptsetup.md#
----------8<----------------


For requesting the document listing about/, it writes
----------8<----------------
==> /var/log/apache2/error-repositories-hacking.log <==
[Thu Aug 13 10:45:46.755487 2015] [cgi:error] [pid 7586] [client ::1:60522]
AH01215: cmd url is: #wiki.git/about#, referer: https://********
[Thu Aug 13 10:45:46.755567 2015] [cgi:error] [pid 7586] [client ::1:60522]
AH01215: cmd qryp is: #(null)#, referer: https://********
----------8<----------------



As you can see, there's no trailing slash at that point, even when contained in
the http request. So the check for the trailing slash in cmd.c:49 always
triggers the redirect.

Here's a trace of firefox' "Live HTTP headers" for a request to about/:

----------8<----------------
https://www.****/repositories/cgit/wiki.git/about/

GET /repositories/cgit/wiki.git/about/ HTTP/1.1
Host: www.*****
User-Agent: Mozilla/5.0[...]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Referer: https://www.*****/repositories/cgit/wiki.git/
Connection: keep-alive

HTTP/1.1 301 Moved
Date: Thu, 13 Aug 2015 08:47:41 GMT
Server: Apache
Location: /repositories/cgit/wiki.git/about/
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
Content-Length: 0
Keep-Alive: timeout=5, max=80
Connection: Keep-Alive
----------8<----------------


And here's the corresponding entry from apache2's access.log:
----------8<----------------
::1 - - [13/Aug/2015:10:47:41 +0200] "GET /repositories/cgit/wiki.git/about/
HTTP/1.1" 301 4611 "https://***/repositories/cgit/wiki.git/" "Mozilla/5.0[...]"
----------8<----------------


Hauler if you need additional info.


Cheers
Daniel



  reply	other threads:[~2015-08-13  8:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-12 13:17 Jason
2015-08-13  8:58 ` hacking [this message]
2015-08-13  9:11   ` Jason

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=55CC5C33.4030609@nachtgeist.net \
    --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).