Update upload.go

This commit is contained in:
ZizzyDizzyMC 2021-02-21 22:43:02 -05:00
parent 4b755bafea
commit 238b612860
1 changed files with 8 additions and 8 deletions

View File

@ -53,6 +53,12 @@ type Upload struct {
} }
func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) { func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
if !strictReferrerCheck(r, getSiteURL(r), []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}) {
badRequestHandler(c, w, r, RespAUTO, "")
return
}
upReq := UploadRequest{}
contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
if err != nil { if err != nil {
upReq.contentSize = 0 upReq.contentSize = 0
@ -62,12 +68,6 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
log.Printf("content size assigned") log.Printf("content size assigned")
log.Print(contentSize) log.Print(contentSize)
} }
if !strictReferrerCheck(r, getSiteURL(r), []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}) {
badRequestHandler(c, w, r, RespAUTO, "")
return
}
upReq := UploadRequest{}
uploadHeaderProcess(r, &upReq) uploadHeaderProcess(r, &upReq)
contentType := r.Header.Get("Content-Type") contentType := r.Header.Get("Content-Type")
@ -136,6 +136,7 @@ func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
} }
func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) { func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) {
upReq := UploadRequest{}
contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64) contentSize, err := strconv.ParseInt(r.Header.Get("Content-Length"), 10, 64)
if err != nil { if err != nil {
upReq.contentSize = 0 upReq.contentSize = 0
@ -145,9 +146,8 @@ func uploadPutHandler(c web.C, w http.ResponseWriter, r *http.Request) {
log.Printf("content size assigned") log.Printf("content size assigned")
log.Print(contentSize) log.Print(contentSize)
} }
upReq := UploadRequest{}
uploadHeaderProcess(r, &upReq) uploadHeaderProcess(r, &upReq)
defer r.Body.Close() defer r.Body.Close()
upReq.filename = c.URLParams["name"] upReq.filename = c.URLParams["name"]
upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize) upReq.src = http.MaxBytesReader(w, r.Body, Config.maxSize)