/about redirected to /about/

Daniel Reichelt hacking at nachtgeist.net
Thu Aug 13 10:58:27 CEST 2015


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



More information about the CGit mailing list