Skip to content

Commit

Permalink
Directory traversal with malformed HTTP request
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Apr 22, 2024
1 parent c7bebfc commit 0adffe6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions handler/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func Convert(c *fiber.Ctx) error {
// 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

// normal http request will start with /
if !strings.HasPrefix(c.Path(), "/") {
_ = c.SendStatus(http.StatusBadRequest)
return nil
}

var (
reqHostname = c.Hostname()
reqHost = c.Protocol() + "://" + reqHostname // http://www.example.com:8000
Expand Down

0 comments on commit 0adffe6

Please sign in to comment.