From 829b807a91f9895e3f4b262f688a8d0d9a44caf6 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Sat, 24 Feb 2024 06:47:11 +0800 Subject: Fix tarball/zipball download bug (#29342) (#29352) Backport #29342 by @Zettat123 Fix #29249 ~~Use the `/repos/{owner}/{repo}/archive/{archive}` API to download.~~ Apply #26430 to archive download URLs. Co-authored-by: Zettat123 --- services/auth/auth.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'services/auth/auth.go') diff --git a/services/auth/auth.go b/services/auth/auth.go index 713463a3d4..2d43707518 100644 --- a/services/auth/auth.go +++ b/services/auth/auth.go @@ -38,6 +38,7 @@ func isContainerPath(req *http.Request) bool { var ( gitRawOrAttachPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/)|(?:attachments/))`) lfsPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`) + archivePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/archive/`) ) func isGitRawOrAttachPath(req *http.Request) bool { @@ -54,6 +55,10 @@ func isGitRawOrAttachOrLFSPath(req *http.Request) bool { return false } +func isArchivePath(req *http.Request) bool { + return archivePathRe.MatchString(req.URL.Path) +} + // handleSignIn clears existing session variables and stores new ones for the specified user object func handleSignIn(resp http.ResponseWriter, req *http.Request, sess SessionStore, user *user_model.User) { // We need to regenerate the session... -- cgit v1.2.3