From 77495faae4235c0d9da061d0cce76f23c1ecc431 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:18:53 -0700 Subject: Drop the query-string form of every link cgit falls back to SCRIPT_NAME for virtual_root whenever cgitrc leaves it out, so the ?url= and ?r= forms only ever reached an error page raised while cgitrc was still being read. The page argument of cgit_add_hidden_formfields fed only the url field, so it is unused until its callers stop passing it. --- source/ui-shared.c | 113 ++++++++++++++--------------------------------------- 1 file changed, 30 insertions(+), 83 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index 506cfe2..0f1f27a 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -1,11 +1,10 @@ /* * The output every cgit page has in common. A link from one page to another is - * built here because only this file knows whether a site addresses a request - * as a path below a virtual root or as a query string, and the two are spelled - * differently down to the separator between arguments. The headers, the - * document head, the header block, the footer, the error page and the age - * column are here so that a page handler is left with only its own body to - * produce. + * built here, as a path below the virtual root followed by the arguments the + * target page needs, so that every page spells its urls the same way. The + * headers, the document head, the header block, the footer, the error page and + * the age column are here so that a page handler is left with only its own body + * to produce. */ #define USE_THE_REPOSITORY_VARIABLE @@ -35,20 +34,12 @@ // into a tab title while it still leaves room to spare in that buffer. #define MAX_TITLE_PATH_LEN 256 -static const char *root_url(void) -{ - if (ctx.cfg.virtual_root) - return ctx.cfg.virtual_root; - else - return ctx.cfg.script_name; -} - static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) { const char *delim = "?"; if (always_root || page) - html_attr(root_url()); + html_attr(ctx.cfg.virtual_root); else { char *currenturl = cgit_currenturl(); html_attr(currenturl); @@ -111,36 +102,20 @@ static void site_link(const char *page, const char *name, const char *title, } /* - * Write the url naming the repository, the page and the path, and return - * whether the url has opened its query string already. + * Write the url naming the repository, the page and the path. */ -static int write_page_url(const char *page, const char *path) -{ - if (ctx.cfg.virtual_root) { - html_url_path(ctx.cfg.virtual_root); - html_url_path(ctx.repo->url); - if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') - html("/"); - if (page) { - html_url_path(page); - html("/"); - if (path) - html_url_path(path); - } - return 0; - } - html_url_path(ctx.cfg.script_name); - html("?url="); - html_url_arg(ctx.repo->url); +static void write_page_url(const char *page, const char *path) +{ + html_url_path(ctx.cfg.virtual_root); + html_url_path(ctx.repo->url); if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/') html("/"); if (page) { - html_url_arg(page); + html_url_path(page); html("/"); if (path) - html_url_arg(path); + html_url_path(path); } - return 1; } /* @@ -160,7 +135,7 @@ static int head_is_named(const char *head) static const char *repolink(const char *title, const char *class, const char *page, const char *head, const char *path) { - const char *delim; + const char *delim = "?"; html("cgit logo\n"); @@ -628,8 +603,7 @@ static void print_repo_tabs(void) static void print_repo_search(void) { html("