浏览代码

Verify repository is not bare before retrieving blob. (#3996)

cybe 8 年之前
父节点
当前提交
740192564b
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      routers/api/v1/repo/file.go

+ 5 - 0
routers/api/v1/repo/file.go

@@ -19,6 +19,11 @@ func GetRawFile(ctx *context.APIContext) {
 		return
 		return
 	}
 	}
 
 
+	if ctx.Repo.Repository.IsBare {
+		ctx.Status(404)
+		return
+	}
+
 	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
 	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
 	if err != nil {
 	if err != nil {
 		if git.IsErrNotExist(err) {
 		if git.IsErrNotExist(err) {