@@ -62,6 +62,11 @@ func addFile(path string, d *requestContext, tarWriter *tar.Writer, zipWriter *z
6262 source := splitFile [0 ]
6363 path = splitFile [1 ]
6464 var err error
65+ source , err = url .QueryUnescape (source )
66+ if err != nil {
67+ return fmt .Errorf ("invalid source encoding: %v" , err )
68+ }
69+ fmt .Println ("source" , source )
6570 userScope := "/"
6671 if d .user .Username != "publicUser" {
6772 userScope , err = settings .GetScopeFromSourceName (d .user .Scopes , source )
@@ -188,8 +193,13 @@ func rawFilesHandler(w http.ResponseWriter, r *http.Request, d *requestContext,
188193
189194 firstFileSource := splitFile [0 ]
190195 firstFilePath := splitFile [1 ]
191- fileName := filepath . Base ( firstFilePath )
196+ // decode url encoded source name
192197 var err error
198+ firstFileSource , err = url .QueryUnescape (firstFileSource )
199+ if err != nil {
200+ return http .StatusBadRequest , fmt .Errorf ("invalid source encoding: %v" , err )
201+ }
202+ fileName := filepath .Base (firstFilePath )
193203 userscope := "/"
194204 if d .user .Username != "publicUser" {
195205 userscope , err = settings .GetScopeFromSourceName (d .user .Scopes , firstFileSource )
@@ -323,11 +333,15 @@ func computeArchiveSize(fileList []string, d *requestContext) (int64, error) {
323333 }
324334 source := splitFile [0 ]
325335 path := splitFile [1 ]
336+ var err error
337+ source , err = url .QueryUnescape (source )
338+ if err != nil {
339+ return http .StatusBadRequest , fmt .Errorf ("invalid source encoding: %v" , err )
340+ }
326341 idx := indexing .GetIndex (source )
327342 if idx == nil {
328343 return 0 , fmt .Errorf ("source %s is not available" , source )
329344 }
330- var err error
331345 userScope := "/"
332346 if d .user .Username != "publicUser" {
333347 userScope , err = settings .GetScopeFromSourceName (d .user .Scopes , source )
@@ -342,7 +356,10 @@ func computeArchiveSize(fileList []string, d *requestContext) (int64, error) {
342356 indexPath := idx .MakeIndexPath (realPath )
343357 info , ok := idx .GetReducedMetadata (indexPath , isDir )
344358 if ! ok {
345- return 0 , fmt .Errorf ("failed to get metadata info for %s" , path )
359+ info , err = idx .GetFsDirInfo (indexPath )
360+ if err != nil {
361+ return 0 , fmt .Errorf ("failed to get file info for %s : %v" , path , err )
362+ }
346363 }
347364 estimatedSize += info .Size
348365 }
0 commit comments