mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-17 04:32:15 +01:00
avoir directory traversal when uploading a file
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
|
"github.com/thecodingmachine/gotenberg/internal/app/xhttp/pkg/resource"
|
||||||
@@ -106,7 +107,9 @@ func (ctx *Context) WithResource(directoryName string) error {
|
|||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
defer in.Close() // nolint: errcheck
|
defer in.Close() // nolint: errcheck
|
||||||
if err := r.WithFile(fh.Filename, in); err != nil {
|
// avoid directory traversal.
|
||||||
|
filename := filepath.Base(fh.Filename)
|
||||||
|
if err := r.WithFile(filename, in); err != nil {
|
||||||
return r, err
|
return r, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user