@@ -10,6 +10,7 @@ import (
10
10
"io/ioutil"
11
11
"log"
12
12
"net/http"
13
+ "path/filepath"
13
14
"strconv"
14
15
"strings"
15
16
@@ -279,7 +280,7 @@ func (s *HTTPServer) handlePostSeq(w http.ResponseWriter, r *http.Request) {
279
280
280
281
func (s * HTTPServer ) handlePostFile (w http.ResponseWriter , r * http.Request ) {
281
282
u := s .charmUserFromRequest (w , r )
282
- path := pattern .Path (r .Context ())
283
+ path := filepath . Clean ( pattern .Path (r .Context () ))
283
284
ms := r .URL .Query ().Get ("mode" )
284
285
m , err := strconv .ParseUint (ms , 10 , 32 )
285
286
if err != nil {
@@ -316,7 +317,7 @@ func (s *HTTPServer) handlePostFile(w http.ResponseWriter, r *http.Request) {
316
317
317
318
func (s * HTTPServer ) handleGetFile (w http.ResponseWriter , r * http.Request ) {
318
319
u := s .charmUserFromRequest (w , r )
319
- path := pattern .Path (r .Context ())
320
+ path := filepath . Clean ( pattern .Path (r .Context () ))
320
321
f , err := s .cfg .FileStore .Get (u .CharmID , path )
321
322
if errors .Is (err , fs .ErrNotExist ) {
322
323
s .renderCustomError (w , "file not found" , http .StatusNotFound )
@@ -353,7 +354,7 @@ func (s *HTTPServer) handleGetFile(w http.ResponseWriter, r *http.Request) {
353
354
354
355
func (s * HTTPServer ) handleDeleteFile (w http.ResponseWriter , r * http.Request ) {
355
356
u := s .charmUserFromRequest (w , r )
356
- path := pattern .Path (r .Context ())
357
+ path := filepath . Clean ( pattern .Path (r .Context () ))
357
358
err := s .cfg .FileStore .Delete (u .CharmID , path )
358
359
if err != nil {
359
360
log .Printf ("cannot delete file: %s" , err )
0 commit comments