From e8671e5f11c1d64d539cf4677808e7617c94d050 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:36:07 -1000 Subject: Hand the about filter the tree url its links need With nothing below the about page, a readme's relative links have to be written against the tree, and only cgit knows how this site spells the url of a tree page and which ref the readme was read from. Both reach the filter already escaped for a url, built by the same writer as cgit's own links. --- source/ui-summary.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source/ui-summary.c') diff --git a/source/ui-summary.c b/source/ui-summary.c index e7b229a..44abc6b 100644 --- a/source/ui-summary.c +++ b/source/ui-summary.c @@ -91,14 +91,22 @@ void cgit_print_repo_readme(void) } html(""); } else { + struct strbuf tree_base = STRBUF_INIT, tree_query = STRBUF_INIT; + + // A tracked readme's links lead into the tree at the ref it was + // read from, while one on disk has no tree to lead into. + if (ref) + cgit_tree_url(ref, &tree_base, &tree_query); // The filter is what makes the source safe here, so it is fed // through unescaped. - cgit_open_filter(ctx.repo->about_filter, filename); + cgit_open_filter(ctx.repo->about_filter, filename, tree_base.buf, tree_query.buf); if (ref) cgit_print_file(filename, ref, 1, 0); else html_include(filename); cgit_close_filter(ctx.repo->about_filter); + strbuf_release(&tree_base); + strbuf_release(&tree_query); } html(""); cgit_print_layout_end(); -- cgit