diff options
| author | Julian Maurice | 2014-03-28 23:18:29 +0100 |
|---|---|---|
| committer | Jason A. Donenfeld | 2014-04-05 19:05:36 -0300 |
| commit | 10451797fa2370aab6f4146c86e0fa939a9a982b (patch) | |
| tree | 3fb006eb4c87b9777032db53040d923ff3794340 /parsing.c | |
| parent | 88b93113235452d47e7ce474689327c43e64b843 (diff) | |
| download | cgit-10451797fa2370aab6f4146c86e0fa939a9a982b.tar.gz cgit-10451797fa2370aab6f4146c86e0fa939a9a982b.tar.bz2 cgit-10451797fa2370aab6f4146c86e0fa939a9a982b.zip | |
Fix cgit_parse_url when a repo url is contained in another repo url
For example, if I have two repos (remove-suffix is enabled):
/foo
/foo/bar
http://cgit/foo/bar/ is interpreted as "repository 'foo', command 'bar'"
instead of "repository 'foo/bar'"
Diffstat (limited to 'parsing.c')
| -rw-r--r-- | parsing.c | 23 |
1 files changed, 14 insertions, 9 deletions
| @@ -17,7 +17,8 @@ | |||
| 17 | */ | 17 | */ |
| 18 | void cgit_parse_url(const char *url) | 18 | void cgit_parse_url(const char *url) |
| 19 | { | 19 | { |
| 20 | char *cmd, *p; | 20 | char *c, *cmd, *p; |
| 21 | struct cgit_repo *repo; | ||
| 21 | 22 | ||
| 22 | ctx.repo = NULL; | 23 | ctx.repo = NULL; |
| 23 | if (!url || url[0] == '\0') | 24 | if (!url || url[0] == '\0') |
| @@ -29,16 +30,20 @@ void cgit_parse_url(const char *url) | |||
| 29 | return; | 30 | return; |
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | cmd = strchr(url, '/'); | 33 | cmd = NULL; |
| 33 | while (!ctx.repo && cmd) { | 34 | c = strchr(url, '/'); |
| 34 | cmd[0] = '\0'; | 35 | while (c) { |
| 35 | ctx.repo = cgit_get_repoinfo(url); | 36 | c[0] = '\0'; |
| 36 | if (ctx.repo == NULL) { | 37 | repo = cgit_get_repoinfo(url); |
| 37 | cmd[0] = '/'; | 38 | if (repo) { |
| 38 | cmd = strchr(cmd + 1, '/'); | 39 | ctx.repo = repo; |
| 39 | continue; | 40 | cmd = c; |
| 40 | } | 41 | } |
| 42 | c[0] = '/'; | ||
| 43 | c = strchr(c + 1, '/'); | ||
| 44 | } | ||
| 41 | 45 | ||
| 46 | if (ctx.repo) { | ||
| 42 | ctx.qry.repo = ctx.repo->url; | 47 | ctx.qry.repo = ctx.repo->url; |
| 43 | p = strchr(cmd + 1, '/'); | 48 | p = strchr(cmd + 1, '/'); |
| 44 | if (p) { | 49 | if (p) { |
