at work
This commit is contained in:
@@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
// "strings"
|
||||
|
||||
"filer/pkg/logger"
|
||||
|
||||
@@ -23,20 +23,22 @@ type Handler struct {
|
||||
func NewHandler(conf *HandlerConfig) (*Handler, error) {
|
||||
var err error
|
||||
hand := &Handler{
|
||||
log: logger.NewLogger("handler"),
|
||||
datadir: conf.Datadir,
|
||||
log: logger.NewLogger("handler"),
|
||||
}
|
||||
return hand, err
|
||||
}
|
||||
|
||||
func (hand *Handler) GetFile(gctx *gin.Context) {
|
||||
filePath := gctx.FullPath()
|
||||
filePath := gctx.Request.URL.Path
|
||||
localFilePath := filepath.Join(hand.datadir, filePath)
|
||||
|
||||
if strings.Contains(localFilePath, "/../") {
|
||||
gctx.Status(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if len(filePath) > 0 && fileExists(localFilePath) {
|
||||
hand.log.Debugf("Send file %s", localFilePath)
|
||||
// if strings.Contains(localFilePath, "/../") {
|
||||
// gctx.Status(http.StatusBadRequest)
|
||||
// return
|
||||
// }
|
||||
if filePath != "" && fileExists(localFilePath) {
|
||||
gctx.FileAttachment(localFilePath, filepath.Base(filePath))
|
||||
return
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user