List for cgit developers and users
 help / color / mirror / Atom feed
* /about redirected to /about/
@ 2015-08-12 13:17 Jason
  2015-08-13  8:58 ` hacking
  0 siblings, 1 reply; 3+ messages in thread
From: Jason @ 2015-08-12 13:17 UTC (permalink / raw)


Hi folks,

All our links were already pointing to /about/, but it was still
possible to load the same content at /about. This posed a problem for
using relative links inside markdown or wiki pages. This commit adds
support for a 301 redirect:

http://git.zx2c4.com/cgit/commit/?id=d7034806a4b1279f62d606501f831dcad31798e6

Please let me know if this poses any problems.

Thanks,
Jason


^ permalink raw reply	[flat|nested] 3+ messages in thread

* /about redirected to /about/
  2015-08-12 13:17 /about redirected to /about/ Jason
@ 2015-08-13  8:58 ` hacking
  2015-08-13  9:11   ` Jason
  0 siblings, 1 reply; 3+ messages in thread
From: hacking @ 2015-08-13  8:58 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* /about redirected to /about/
  2015-08-13  8:58 ` hacking
@ 2015-08-13  9:11   ` Jason
  0 siblings, 0 replies; 3+ messages in thread
From: Jason @ 2015-08-13  9:11 UTC (permalink / raw)


Hey Daniel,

Can you hop on IRC and debug this interactively with me?

#cgit on freenode. I'm zx2c4.

Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20150813/a9a48b91/attachment.html>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-13  9:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 13:17 /about redirected to /about/ Jason
2015-08-13  8:58 ` hacking
2015-08-13  9:11   ` Jason

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).