|
@@ -121,6 +121,11 @@ type UpdateRepoFileOptions struct {
|
|
|
|
|
|
|
|
|
|
func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error) {
|
|
func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (err error) {
|
|
|
|
+
|
|
|
|
+ if isRepositoryGitPath(opts.NewTreeName) {
|
|
|
|
+ return errors.Errorf("bad tree path %q", opts.NewTreeName)
|
|
|
|
+ }
|
|
|
|
+
|
|
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
|
|
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
|
|
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
|
|
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
|
|
|
|
|
|
@@ -458,7 +463,8 @@ type UploadRepoFileOptions struct {
|
|
Files []string
|
|
Files []string
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
|
|
+
|
|
func isRepositoryGitPath(path string) bool {
|
|
func isRepositoryGitPath(path string) bool {
|
|
return strings.HasSuffix(path, ".git") ||
|
|
return strings.HasSuffix(path, ".git") ||
|
|
strings.Contains(path, ".git"+string(os.PathSeparator)) ||
|
|
strings.Contains(path, ".git"+string(os.PathSeparator)) ||
|
|
@@ -472,7 +478,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
if isRepositoryGitPath(opts.TreePath) {
|
|
if isRepositoryGitPath(opts.TreePath) {
|
|
return errors.Errorf("bad tree path %q", opts.TreePath)
|
|
return errors.Errorf("bad tree path %q", opts.TreePath)
|
|
}
|
|
}
|
|
@@ -512,7 +518,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, opts UploadRepoFileOptions)
|
|
|
|
|
|
upload.Name = pathutil.Clean(upload.Name)
|
|
upload.Name = pathutil.Clean(upload.Name)
|
|
|
|
|
|
-
|
|
+
|
|
if isRepositoryGitPath(upload.Name) {
|
|
if isRepositoryGitPath(upload.Name) {
|
|
continue
|
|
continue
|
|
}
|
|
}
|