about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJohn Keeping2017-10-14 13:02:53 +0100
committerJason A. Donenfeld2017-10-14 14:31:18 +0200
commit9d751e7eec4f4bc7292be46f2af774fe1adf336a (patch)
tree332b2ed294743969237886944f6b263d8ed0acc6
parentui-tree: link to blame UI if enabled (diff)
downloadcgit-9d751e7eec4f4bc7292be46f2af774fe1adf336a.tar.gz
cgit-9d751e7eec4f4bc7292be46f2af774fe1adf336a.zip
parsing: don't clear existing state with empty input
Since commit c699866 (parsing: clear query path before starting,
2017-02-19), we clear the "page" variable simply by calling
cgit_parse_url() even if the URL is empty.  This breaks a URL like:

	.../cgit?p=about

which is generated when using the "root-readme" configuration option.

This happens because "page" is set to "about" when parsing the query
string before we handle the path (which is empty, but non-null).

It turns out that this is not the only case which is broken, but
specifying repository and page via query options has been broken since
before the commit mentioned above, for example:

	.../cgit?r=git&p=log

Fix both of these by allowing the previous state to persist if PATH_INFO
is empty, falling back to the query parameters if no path has been
requested.

Reported-by: Tom Ryder <tom@sanctum.geek.nz>
Signed-off-by: John Keeping <john@keeping.me.uk>
-rw-r--r--parsing.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/parsing.c b/parsing.c index b8d7f10..fd1ea99 100644 --- a/parsing.c +++ b/parsing.c
@@ -20,11 +20,10 @@ void cgit_parse_url(const char *url)
20 char *c, *cmd, *p; 20 char *c, *cmd, *p;
21 struct cgit_repo *repo; 21 struct cgit_repo *repo;
22 22
23 ctx.repo = NULL;
24 ctx.qry.page = NULL;
25 if (!url || url[0] == '\0') 23 if (!url || url[0] == '\0')
26 return; 24 return;
27 25
26 ctx.qry.page = NULL;
28 ctx.repo = cgit_get_repoinfo(url); 27 ctx.repo = cgit_get_repoinfo(url);
29 if (ctx.repo) { 28 if (ctx.repo) {
30 ctx.qry.repo = ctx.repo->url; 29 ctx.qry.repo = ctx.repo->url;