Skip to content
Permalink
Browse files

Cleanup

  • Loading branch information
andreimarcu committed Oct 15, 2015
1 parent 3c65960 commit 9847beeff5c1bba4a15fe4254b63670aeb62a2c1
Showing with 2 additions and 12 deletions.
  1. +1 −5 csrf.go
  2. +1 −7 upload.go
@@ -8,7 +8,7 @@ import (
// Do a strict referrer check, matching against both the Origin header (if
// present) and the Referrer header. If a list of headers is specified, then
// Referrer checking will be skipped if any of those headers are present.
func strictReferrerCheck(r *http.Request, prefix string, whitelistHeaders []string, allowBlank bool) bool {
func strictReferrerCheck(r *http.Request, prefix string, whitelistHeaders []string) bool {
p, _ := url.Parse(prefix)

// if there's an Origin header, check it and skip other checks
@@ -25,10 +25,6 @@ func strictReferrerCheck(r *http.Request, prefix string, whitelistHeaders []stri

referrer := r.Header.Get("Referer")

if allowBlank && referrer == "" {
return true
}

u, _ := url.Parse(referrer)
return sameOrigin(u, p)
}
@@ -46,7 +46,7 @@ type Upload struct {
}

func uploadPostHandler(c web.C, w http.ResponseWriter, r *http.Request) {
if !strictReferrerCheck(r, Config.siteURL, []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}, false) {
if !strictReferrerCheck(r, Config.siteURL, []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}) {
badRequestHandler(c, w, r)
return
}
@@ -144,12 +144,6 @@ func uploadRemote(c web.C, w http.ResponseWriter, r *http.Request) {
unauthorizedHandler(c, w, r)
return
}
} else {
// strict referrer checking is mandatory without remote auth keys
if !strictReferrerCheck(r, Config.siteURL, []string{"Linx-Delete-Key", "Linx-Expiry", "Linx-Randomize", "X-Requested-With"}, true) {
badRequestHandler(c, w, r)
return
}
}

if r.FormValue("url") == "" {

0 comments on commit 9847bee

Please sign in to comment.
You can’t perform that action at this time.