Skip to content

Make sure lfs will only support relative path #23446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion routers/web/repo/lfs.go
Original file line number Diff line number Diff line change
@@ -207,7 +207,7 @@ func LFSLockFile(ctx *context.Context) {
ctx.Redirect(ctx.Repo.RepoLink + "/settings/lfs/locks")
return
}
lockPath = util.CleanPath(lockPath)
lockPath = strings.TrimPrefix(util.CleanPath(lockPath), "/")
if len(lockPath) == 0 {
ctx.Flash.Error(ctx.Tr("repo.settings.lfs_invalid_locking_path", originalPath))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/lfs/locks")
13 changes: 10 additions & 3 deletions services/lfs/locks.go
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ func GetListLockHandler(ctx *context.Context) {
return
}

path := ctx.FormString("path")
path := strings.TrimPrefix(ctx.FormString("path"), "/")
if path != "" { // Case where we request a specific id
lock, err := git_model.GetLFSLock(ctx, repository, path)
if err != nil && !git_model.IsErrLFSLockNotExist(err) {
@@ -143,7 +143,14 @@ func PostLockHandler(ctx *context.Context) {
})
return
}
repository.MustOwner(ctx)
if err := repository.LoadOwner(ctx); err != nil {
log.Error("Unable to LoadOwner: %s/%s Error: %v", userName, repoName, err)
ctx.Resp.Header().Set("WWW-Authenticate", "Basic realm=gitea-lfs")
ctx.JSON(http.StatusUnauthorized, api.LFSLockError{
Message: "Something error with server",
})
return
}

authenticated := authenticate(ctx, repository, authorization, true, true)
if !authenticated {
@@ -168,7 +175,7 @@ func PostLockHandler(ctx *context.Context) {
}

lock, err := git_model.CreateLFSLock(ctx, repository, &git_model.LFSLock{
Path: req.Path,
Path: strings.TrimPrefix(req.Path, "/"),
OwnerID: ctx.Doer.ID,
})
if err != nil {