diff --git a/cmd/integration-test/http.go b/cmd/integration-test/http.go index 0df2a0490..95a458d86 100644 --- a/cmd/integration-test/http.go +++ b/cmd/integration-test/http.go @@ -23,6 +23,7 @@ var httpTestcases = map[string]testutils.TestCase{ "Regression test for: https://github.com/projectdiscovery/httpx/issues/303": &issue303{}, // misconfigured gzip header with uncompressed body "Regression test for: https://github.com/projectdiscovery/httpx/issues/400": &issue400{}, // post operation with body "Regression test for: https://github.com/projectdiscovery/httpx/issues/414": &issue414{}, // stream mode with path + "Regression test for: https://github.com/projectdiscovery/httpx/issues/433": &issue433{}, // new line scanning with title flag } type standardHttpGet struct { @@ -238,3 +239,28 @@ func (h *issue414) Execute() error { } return nil } + +type issue433 struct{} + +func (h *issue433) Execute() error { + var ts *httptest.Server + router := httprouter.New() + uriPath := "/index" + router.GET(uriPath, httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { + htmlResponse := "Project\n\r Discovery\n - Httpx>test data" + fmt.Fprint(w, htmlResponse) + })) + ts = httptest.NewServer(router) + defer ts.Close() + results, err := testutils.RunHttpxAndGetResults(fmt.Sprint(ts.URL, uriPath), debug, "-title", "-no-color") + if err != nil { + return err + } + if strings.Contains(results[0], "\n") { + return errIncorrectResultsCount(results) + } + if strings.Contains(results[0], "\r") { + return errIncorrectResultsCount(results) + } + return nil +} diff --git a/common/httpx/title.go b/common/httpx/title.go index 1edb53431..ba1c7e3f9 100644 --- a/common/httpx/title.go +++ b/common/httpx/title.go @@ -34,6 +34,8 @@ func ExtractTitle(r *Response) (title string) { // remove unwanted chars title = strings.TrimSpace(strings.Trim(title, cutset)) + title = strings.ReplaceAll(title, "\n", "") + title = strings.ReplaceAll(title, "\r", "") // Non UTF-8 if contentTypes, ok := r.Headers["Content-Type"]; ok {