From a102fa8748a836d031e2e0e263b58af8c855332f Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 1 Oct 2026 17:12:28 -1000 Subject: 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. --- source/ui-shared.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/ui-shared.h') diff --git a/source/ui-shared.h b/source/ui-shared.h index 4809bc1..c4b96a9 100644 --- a/source/ui-shared.h +++ b/source/ui-shared.h @@ -18,10 +18,12 @@ extern char *cgit_hosturl(void); /* * The URL of the request being answered, which cgit_currentfullurl gives with * the query string on the end as well, minus the url argument that the path - * was taken from. + * was taken from. cgit_currentquery is that query string alone, led by its + * question mark, or an empty string when nothing is left of it. */ extern char *cgit_currenturl(void); extern char *cgit_currentfullurl(void); +extern char *cgit_currentquery(void); extern const char *cgit_loginurl(void); extern char *cgit_repourl(const char *reponame); extern void cgit_print_clone_row(const char *url, int colspan); @@ -85,7 +87,11 @@ extern struct date_mode cgit_date_mode(enum date_mode_type type); */ extern void cgit_print_age(time_t t, int tz, time_t max_relative); extern void cgit_print_http_headers(void); -extern void cgit_redirect(const char *url, bool permanent); +/* + * Answer with a redirect to url, followed by query when one is given, which + * is written as it arrived. + */ +extern void cgit_redirect(const char *url, const char *query, bool permanent); extern void cgit_print_docstart(void); extern void cgit_print_docend(void); __attribute__((format (printf,3,4))) -- cgit v2.8.0