diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-07 20:25:30 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-07 20:27:13 +0800 |
commit | 67083d3173197c0a247f7b32300ee007749fa939 (patch) | |
tree | b6845c08dc01caa79da6a7350509b8c7127cc56f /http_handle_repo_index.go | |
parent | hooks: Simplify comments in the hook client (diff) | |
download | forge-67083d3173197c0a247f7b32300ee007749fa939.tar.gz forge-67083d3173197c0a247f7b32300ee007749fa939.tar.zst forge-67083d3173197c0a247f7b32300ee007749fa939.zip |
repo/index: Emit warning when path contains newline
Diffstat (limited to 'http_handle_repo_index.go')
-rw-r--r-- | http_handle_repo_index.go | 7 |
1 files changed, 7 insertions, 0 deletions
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) } |