Skip to content

Commit 829b807

Browse files
GiteaBotZettat123
andauthored
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 <[email protected]>
1 parent 874cdcc commit 829b807

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

services/auth/auth.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func isContainerPath(req *http.Request) bool {
3838
var (
3939
gitRawOrAttachPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/)|(?:attachments/))`)
4040
lfsPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`)
41+
archivePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/archive/`)
4142
)
4243

4344
func isGitRawOrAttachPath(req *http.Request) bool {
@@ -54,6 +55,10 @@ func isGitRawOrAttachOrLFSPath(req *http.Request) bool {
5455
return false
5556
}
5657

58+
func isArchivePath(req *http.Request) bool {
59+
return archivePathRe.MatchString(req.URL.Path)
60+
}
61+
5762
// handleSignIn clears existing session variables and stores new ones for the specified user object
5863
func handleSignIn(resp http.ResponseWriter, req *http.Request, sess SessionStore, user *user_model.User) {
5964
// We need to regenerate the session...

services/auth/oauth2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (o *OAuth2) userIDFromToken(ctx context.Context, tokenSHA string, store Dat
133133
func (o *OAuth2) Verify(req *http.Request, w http.ResponseWriter, store DataStore, sess SessionStore) (*user_model.User, error) {
134134
// These paths are not API paths, but we still want to check for tokens because they maybe in the API returned URLs
135135
if !middleware.IsAPIPath(req) && !isAttachmentDownload(req) && !isAuthenticatedTokenRequest(req) &&
136-
!isGitRawOrAttachPath(req) {
136+
!isGitRawOrAttachPath(req) && !isArchivePath(req) {
137137
return nil, nil
138138
}
139139

0 commit comments

Comments
 (0)