no need for additional decode (#81)
file paths used to be url-encoded twice, which is no longer the case.
This commit is contained in:
		
							parent
							
								
									a822c7c340
								
							
						
					
					
						commit
						3f6eb7e41a
					
				|  | @ -2,14 +2,6 @@ package router | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"emperror.dev/errors" |  | ||||||
| 	"github.com/apex/log" |  | ||||||
| 	"github.com/gin-gonic/gin" |  | ||||||
| 	"github.com/pterodactyl/wings/router/downloader" |  | ||||||
| 	"github.com/pterodactyl/wings/router/tokens" |  | ||||||
| 	"github.com/pterodactyl/wings/server" |  | ||||||
| 	"github.com/pterodactyl/wings/server/filesystem" |  | ||||||
| 	"golang.org/x/sync/errgroup" |  | ||||||
| 	"mime/multipart" | 	"mime/multipart" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"net/url" | 	"net/url" | ||||||
|  | @ -18,16 +10,21 @@ import ( | ||||||
| 	"path/filepath" | 	"path/filepath" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
|  | 
 | ||||||
|  | 	"emperror.dev/errors" | ||||||
|  | 	"github.com/apex/log" | ||||||
|  | 	"github.com/gin-gonic/gin" | ||||||
|  | 	"github.com/pterodactyl/wings/router/downloader" | ||||||
|  | 	"github.com/pterodactyl/wings/router/tokens" | ||||||
|  | 	"github.com/pterodactyl/wings/server" | ||||||
|  | 	"github.com/pterodactyl/wings/server/filesystem" | ||||||
|  | 	"golang.org/x/sync/errgroup" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Returns the contents of a file on the server.
 | // Returns the contents of a file on the server.
 | ||||||
| func getServerFileContents(c *gin.Context) { | func getServerFileContents(c *gin.Context) { | ||||||
| 	s := ExtractServer(c) | 	s := ExtractServer(c) | ||||||
| 	f, err := url.QueryUnescape(c.Query("file")) | 	f := c.Query("file") | ||||||
| 	if err != nil { |  | ||||||
| 		WithError(c, err) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	p := "/" + strings.TrimLeft(f, "/") | 	p := "/" + strings.TrimLeft(f, "/") | ||||||
| 	st, err := s.Filesystem().Stat(p) | 	st, err := s.Filesystem().Stat(p) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -64,11 +61,7 @@ func getServerFileContents(c *gin.Context) { | ||||||
| // Returns the contents of a directory for a server.
 | // Returns the contents of a directory for a server.
 | ||||||
| func getServerListDirectory(c *gin.Context) { | func getServerListDirectory(c *gin.Context) { | ||||||
| 	s := ExtractServer(c) | 	s := ExtractServer(c) | ||||||
| 	dir, err := url.QueryUnescape(c.Query("directory")) | 	dir := c.Query("directory") | ||||||
| 	if err != nil { |  | ||||||
| 		WithError(c, err) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	if stats, err := s.Filesystem().ListDirectory(dir); err != nil { | 	if stats, err := s.Filesystem().ListDirectory(dir); err != nil { | ||||||
| 		WithError(c, err) | 		WithError(c, err) | ||||||
| 	} else { | 	} else { | ||||||
|  | @ -212,11 +205,7 @@ func postServerDeleteFiles(c *gin.Context) { | ||||||
| func postServerWriteFile(c *gin.Context) { | func postServerWriteFile(c *gin.Context) { | ||||||
| 	s := GetServer(c.Param("server")) | 	s := GetServer(c.Param("server")) | ||||||
| 
 | 
 | ||||||
| 	f, err := url.QueryUnescape(c.Query("file")) | 	f := c.Query("file") | ||||||
| 	if err != nil { |  | ||||||
| 		NewServerError(err, s).Abort(c) |  | ||||||
| 		return |  | ||||||
| 	} |  | ||||||
| 	f = "/" + strings.TrimLeft(f, "/") | 	f = "/" + strings.TrimLeft(f, "/") | ||||||
| 
 | 
 | ||||||
| 	if err := s.Filesystem().Writefile(f, c.Request.Body); err != nil { | 	if err := s.Filesystem().Writefile(f, c.Request.Body); err != nil { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user