From 67083d3173197c0a247f7b32300ee007749fa939 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 7 Mar 2025 20:25:30 +0800 Subject: repo/index: Emit warning when path contains newline --- http_handle_repo_index.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'http_handle_repo_index.go') diff --git a/http_handle_repo_index.go b/http_handle_repo_index.go index 15b5173..6ac9b07 100644 --- a/http_handle_repo_index.go +++ b/http_handle_repo_index.go @@ -5,6 +5,7 @@ package main import ( "net/http" + "strings" "github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5/plumbing" @@ -20,9 +21,14 @@ func handle_repo_index(w http.ResponseWriter, r *http.Request, params map[string var recent_commits []*object.Commit var commit_object *object.Commit var tree *object.Tree + var notes []string repo, repo_name, group_path = params["repo"].(*git.Repository), params["repo_name"].(string), params["group_path"].([]string) + if strings.Contains(repo_name, "\n") || slice_contains_newline(group_path) { + notes = append(notes, "Path contains newlines; HTTP Git access impossible") + } + ref_hash, err = get_ref_hash_from_type_and_name(repo, params["ref_type"].(string), params["ref_name"].(string)) if err != nil { goto no_ref @@ -48,6 +54,7 @@ no_ref: params["http_clone_url"] = generate_http_remote_url(group_path, repo_name) params["ssh_clone_url"] = generate_ssh_remote_url(group_path, repo_name) + params["notes"] = notes render_template(w, "repo_index", params) } -- cgit v1.2.3