aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorAntoine GIRARD <sapk@users.noreply.github.com>2017-11-29 00:35:23 +0100
committerLauris BH <lauris@nix.lv>2017-11-29 01:35:23 +0200
commit4035ab05fa2d2c8ec95d346fea91cab8211dab17 (patch)
tree623d09ee6ab41eba7307cb3be7ce176458455dab /modules
parentc80d147fa911c2aa711bc3f310d7bef11681230b (diff)
downloadgitea-4035ab05fa2d2c8ec95d346fea91cab8211dab17.tar.gz
gitea-4035ab05fa2d2c8ec95d346fea91cab8211dab17.zip
Fix git lfs path (#3016)
* add suffix .git * Remove Content-Type on GET methods * Add migrations to force creation before any further potential migration
Diffstat (limited to 'modules')
-rw-r--r--modules/lfs/locks.go19
1 files changed, 13 insertions, 6 deletions
diff --git a/modules/lfs/locks.go b/modules/lfs/locks.go
index 38d290e13b..2e776c26a0 100644
--- a/modules/lfs/locks.go
+++ b/modules/lfs/locks.go
@@ -7,6 +7,7 @@ package lfs
import (
"encoding/json"
"strconv"
+ "strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
@@ -16,13 +17,19 @@ import (
"gopkg.in/macaron.v1"
)
-func checkRequest(req macaron.Request) int {
+func checkRequest(req macaron.Request, post bool) int {
if !setting.LFS.StartServer {
return 404
}
- if !MetaMatcher(req) || req.Header.Get("Content-Type") != metaMediaType {
+ if !MetaMatcher(req) {
return 400
}
+ if post {
+ mediaParts := strings.Split(req.Header.Get("Content-Type"), ";")
+ if mediaParts[0] != metaMediaType {
+ return 400
+ }
+ }
return 200
}
@@ -52,7 +59,7 @@ func handleLockListOut(ctx *context.Context, lock *models.LFSLock, err error) {
// GetListLockHandler list locks
func GetListLockHandler(ctx *context.Context) {
- status := checkRequest(ctx.Req)
+ status := checkRequest(ctx.Req, false)
if status != 200 {
writeStatus(ctx, status)
return
@@ -113,7 +120,7 @@ func GetListLockHandler(ctx *context.Context) {
// PostLockHandler create lock
func PostLockHandler(ctx *context.Context) {
- status := checkRequest(ctx.Req)
+ status := checkRequest(ctx.Req, true)
if status != 200 {
writeStatus(ctx, status)
return
@@ -157,7 +164,7 @@ func PostLockHandler(ctx *context.Context) {
// VerifyLockHandler list locks for verification
func VerifyLockHandler(ctx *context.Context) {
- status := checkRequest(ctx.Req)
+ status := checkRequest(ctx.Req, true)
if status != 200 {
writeStatus(ctx, status)
return
@@ -204,7 +211,7 @@ func VerifyLockHandler(ctx *context.Context) {
// UnLockHandler delete locks
func UnLockHandler(ctx *context.Context) {
- status := checkRequest(ctx.Req)
+ status := checkRequest(ctx.Req, true)
if status != 200 {
writeStatus(ctx, status)
return