diff --git a/admin/sync/exercices.go b/admin/sync/exercices.go index 30830a31..dec97460 100644 --- a/admin/sync/exercices.go +++ b/admin/sync/exercices.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "net/url" "path" "strconv" "strings" @@ -235,7 +236,7 @@ func BuildExercice(i Importer, theme *fic.Theme, epath string, dmap *map[int64]* errs = append(errs, fmt.Sprintf("%q: resolution.mp4: The file is empty!", edir)) e.VideoURI = "" } else { - e.VideoURI = path.Join("$FILES$", e.VideoURI) + e.VideoURI = strings.Replace(url.PathEscape(path.Join("$FILES$", e.VideoURI)), "%2F", "/", -1) resolutionFound = true } diff --git a/frontend/resolution.go b/frontend/resolution.go index b75ec796..3d553724 100644 --- a/frontend/resolution.go +++ b/frontend/resolution.go @@ -3,13 +3,15 @@ package main import ( "log" "net/http" + "net/url" "path" + "strings" "text/template" ) var enableResolutionRoute bool = false -type ResolutionHandler struct {} +type ResolutionHandler struct{} const resolutiontpl = ` @@ -40,7 +42,7 @@ func (s ResolutionHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { if resolutionTmpl, err := template.New("resolution").Parse(resolutiontpl); err != nil { log.Println("Cannot create template: ", err) - } else if err = resolutionTmpl.Execute(w, path.Join("/vids/", r.URL.Path)); err != nil { + } else if err = resolutionTmpl.Execute(w, path.Join("/vids/", strings.Replace(url.PathEscape(r.URL.Path), "%2F", "/", -1))); err != nil { log.Println("An error occurs during template execution: ", err) } }