mirror of
https://github.com/jech/galene.git
synced 2024-11-14 12:45:58 +01:00
Normalise recordings URLs.
This commit is contained in:
parent
cf9c0edb89
commit
f1a8f2a307
1 changed files with 25 additions and 6 deletions
|
@ -439,14 +439,33 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
group := path.Dir(p[1:])
|
var group, filename string
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
u := r.URL.Path
|
for len(p) > 0 && p[len(p)-1] == '/' {
|
||||||
if u[len(u)-1] != '/' {
|
p = p[:len(p)-1]
|
||||||
http.Redirect(w, r, u+"/", http.StatusPermanentRedirect)
|
}
|
||||||
|
group = parseGroupName("/", p)
|
||||||
|
if group == "" {
|
||||||
|
http.Error(w, "bad group name", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
group = p[1:]
|
} else {
|
||||||
|
if p[len(p)-1] == '/' {
|
||||||
|
http.Error(w, "bad group name", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
group, filename = path.Split(p)
|
||||||
|
group = parseGroupName("/", group)
|
||||||
|
if group == "" {
|
||||||
|
http.Error(w, "bad group name", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
u := "/recordings/" + group + "/" + filename
|
||||||
|
if r.URL.Path != u {
|
||||||
|
http.Redirect(w, r, u, http.StatusPermanentRedirect)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ok := checkGroupPermissions(w, r, group)
|
ok := checkGroupPermissions(w, r, group)
|
||||||
|
@ -455,7 +474,7 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if fi.IsDir() {
|
if filename == "" {
|
||||||
if r.Method == "POST" {
|
if r.Method == "POST" {
|
||||||
handleGroupAction(w, r, group)
|
handleGroupAction(w, r, group)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue