diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep the query string across the about redirects
The hop to the trailing-slash form of the about page, and the hop back
to the summary of a repository without a readme, were built from the
path alone, so a request for the about page of another branch landed
on the default one. The query goes into the Location line as the
client sent it, with any byte a header cannot carry percent-encoded.
Diffstat (limited to 'source/cmd.c')
| -rw-r--r-- | source/cmd.c | 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 9 insertions, 4 deletions
diff --git a/source/cmd.c b/source/cmd.c index 38fe596..49c1eb4 100644 --- a/source/cmd.c +++ b/source/cmd.c @@ -34,7 +34,7 @@ static void head_fn(void) static void about_fn(void) { - char *currenturl, *redirect; + char *currenturl, *query, *redirect; size_t path_info_len; if (!ctx.repo) { @@ -43,23 +43,28 @@ static void about_fn(void) } // The about page resolves relative links against its own URL, so it - // only works with a trailing slash. + // only works with a trailing slash. The branch and the rest of the + // query travel along with either redirect. path_info_len = ctx.env.path_info ? strlen(ctx.env.path_info) : 0; if (!ctx.qry.path && (!ctx.qry.url || !*ctx.qry.url || ctx.qry.url[strlen(ctx.qry.url) - 1] != '/') && (!path_info_len || ctx.env.path_info[path_info_len - 1] != '/')) { currenturl = cgit_currenturl(); + query = cgit_currentquery(); redirect = cgit_fmtalloc("%s/", currenturl); - cgit_redirect(redirect, true); + cgit_redirect(redirect, query, true); free(currenturl); + free(query); free(redirect); } else if (ctx.repo->readme.nr) { cgit_print_repo_readme(ctx.qry.path); } else { currenturl = cgit_currenturl(); + query = cgit_currentquery(); redirect = cgit_fmtalloc("%s../", currenturl); - cgit_redirect(redirect, false); + cgit_redirect(redirect, query, false); free(currenturl); + free(query); free(redirect); } } |
