Skip to content

Commit b762a1f

Browse files
authored
Fix tarball/zipball download bug (#29342)
Fix #29249 ~~Use the `/repos/{owner}/{repo}/archive/{archive}` API to download.~~ Apply #26430 to archive download URLs.
1 parent 2a278b9 commit b762a1f

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
@@ -40,6 +40,7 @@ func isContainerPath(req *http.Request) bool {
4040
var (
4141
gitRawOrAttachPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/(?:(?:git-(?:(?:upload)|(?:receive))-pack$)|(?:info/refs$)|(?:HEAD$)|(?:objects/)|(?:raw/)|(?:releases/download/)|(?:attachments/))`)
4242
lfsPathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/info/lfs/`)
43+
archivePathRe = regexp.MustCompile(`^/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+/archive/`)
4344
)
4445

4546
func isGitRawOrAttachPath(req *http.Request) bool {
@@ -56,6 +57,10 @@ func isGitRawOrAttachOrLFSPath(req *http.Request) bool {
5657
return false
5758
}
5859

60+
func isArchivePath(req *http.Request) bool {
61+
return archivePathRe.MatchString(req.URL.Path)
62+
}
63+
5964
// handleSignIn clears existing session variables and stores new ones for the specified user object
6065
func handleSignIn(resp http.ResponseWriter, req *http.Request, sess SessionStore, user *user_model.User) {
6166
// 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)