gout

A static git page generator
git clone https://git.bracken.jp/gout.git
Log | Files | Refs | README | LICENSE

commit 233b8132b5436b0980c16a89d0f6d22f8c637495
parent cc22a17c4d59074449091cfa4e8ad78baf557d9e
Author: Chris Bracken <chris@bracken.jp>
Date:   Fri, 20 Feb 2026 17:37:04 +0900

gopher: run link content through print_gopher_link

Prevents malicious filenames or repo names containing pipes from
breaking gopher map structure.

Diffstat:
Msrc/writer/gopher/page.c | 15+++++++++------
Msrc/writer/gopher/repo_index.c | 4+++-
2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/writer/gopher/page.c b/src/writer/gopher/page.c @@ -74,18 +74,21 @@ void gopher_page_begin(GopherPage* page) { const char* submodules = page->repo->submodules; if (submodules && submodules[0] != '\0') { - fprintf(out, "[1|Submodules|%sfile/%s.gph|server|port]\n", page->relpath, - submodules); + fprintf(out, "[1|Submodules|%sfile/", page->relpath); + print_gopher_link(out, submodules); + fprintf(out, ".gph|server|port]\n"); } const char* readme = page->repo->readme; if (readme && readme[0] != '\0') { - fprintf(out, "[1|README|%sfile/%s.gph|server|port]\n", page->relpath, - readme); + fprintf(out, "[1|README|%sfile/", page->relpath); + print_gopher_link(out, readme); + fprintf(out, ".gph|server|port]\n"); } const char* license = page->repo->license; if (license && license[0] != '\0') { - fprintf(out, "[1|LICENSE|%sfile/%s.gph|server|port]\n", page->relpath, - license); + fprintf(out, "[1|LICENSE|%sfile/", page->relpath); + print_gopher_link(out, license); + fprintf(out, ".gph|server|port]\n"); } fprintf(out, "---\n"); } diff --git a/src/writer/gopher/repo_index.c b/src/writer/gopher/repo_index.c @@ -46,7 +46,9 @@ void gopher_repoindex_add_repo(GopherRepoIndex* index, const GitRepo* repo) { if (repo->last_commit_time > 0) { print_time_short(out, repo->last_commit_time); } - fprintf(out, "|%s/log.gph|server|port]\n", repo->short_name); + fprintf(out, "|"); + print_gopher_link(out, repo->short_name); + fprintf(out, "/log.gph|server|port]\n"); } void gopher_repoindex_end(GopherRepoIndex* index) {