mirror of
https://github.com/woodchen-ink/webp_server_go.git
synced 2025-07-18 13:42:02 +08:00
Fix Malformed dir traversal (#331)
* Directory traversal with malformed HTTP request #330 * bump version * also %2e * Use prefix to check invalid Path --------- Co-authored-by: n0vad3v <n0vad3v@riseup.net>
This commit is contained in:
parent
c7bebfca34
commit
be32328998
@ -50,7 +50,7 @@ var (
|
|||||||
ProxyMode bool
|
ProxyMode bool
|
||||||
Prefetch bool
|
Prefetch bool
|
||||||
Config = NewWebPConfig()
|
Config = NewWebPConfig()
|
||||||
Version = "0.11.2"
|
Version = "0.11.3"
|
||||||
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
|
WriteLock = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
ConvertLock = cache.New(5*time.Minute, 10*time.Minute)
|
ConvertLock = cache.New(5*time.Minute, 10*time.Minute)
|
||||||
RemoteRaw = "./remote-raw"
|
RemoteRaw = "./remote-raw"
|
||||||
|
@ -22,6 +22,12 @@ func Convert(c *fiber.Ctx) error {
|
|||||||
// 2. generate rawImagePath, could be local path or remote url(possible with query string)
|
// 2. generate rawImagePath, could be local path or remote url(possible with query string)
|
||||||
// 3. pass it to encoder, get the result, send it back
|
// 3. pass it to encoder, get the result, send it back
|
||||||
|
|
||||||
|
// normal http request will start with /
|
||||||
|
if !strings.HasPrefix(c.Path(), "/") {
|
||||||
|
_ = c.SendStatus(http.StatusBadRequest)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reqHostname = c.Hostname()
|
reqHostname = c.Hostname()
|
||||||
reqHost = c.Protocol() + "://" + reqHostname // http://www.example.com:8000
|
reqHost = c.Protocol() + "://" + reqHostname // http://www.example.com:8000
|
||||||
|
Loading…
x
Reference in New Issue
Block a user