Skip to content

Commit

Permalink
Merge pull request #6 from kecci/feature/sanitize-uri
Browse files Browse the repository at this point in the history
sanitize uri
  • Loading branch information
kecci authored Jul 26, 2022
2 parents e49aa88 + 6e5acca commit ee1b6b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/http/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ func makeLogEntry(c echo.Context) *log.Entry {
})
}

// Sanitize uri
uri := c.Request().URL.String()
escapedUri := strings.Replace(uri, "\n", "", -1)
escapedUri = strings.Replace(escapedUri, "\r", "", -1)

return log.WithFields(log.Fields{
"at": time.Now().Format("2006-01-02 15:04:05"),
"method": c.Request().Method,
"uri": c.Request().URL.String(),
"uri": escapedUri,
"ip": c.Request().RemoteAddr,
})
}
Expand Down

0 comments on commit ee1b6b9

Please sign in to comment.