the repository which powers this website
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 <[email protected]> Signed-off-by: John Keeping <[email protected]>
John Keeping 2017-10-14
parent 1649afd · commit 9d751e7
-rw-r--r--parsing.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/parsing.c b/parsing.c
index b8d7f10d..fd1ea996 100644
--- a/parsing.c
+++ b/parsing.c
@@ -20,11 +20,10 @@ void cgit_parse_url(const char *url)
char *c, *cmd, *p;
struct cgit_repo *repo;
- ctx.repo = NULL;
- ctx.qry.page = NULL;
if (!url || url[0] == '\0')
return;
+ ctx.qry.page = NULL;
ctx.repo = cgit_get_repoinfo(url);
if (ctx.repo) {
ctx.qry.repo = ctx.repo->url;