Skip to content

Commit

Permalink
Merge pull request #274 from EdisonFu/dev
Browse files Browse the repository at this point in the history
Add header validation to prevent service panic.
  • Loading branch information
adamboutcher committed May 10, 2024
2 parents 6305eb0 + 41a722b commit a2325c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions types/services/routine.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ func CheckSmtp(s *Service, record bool) (*Service, error) {

// check if 'Content-Type' header was defined
for _, header := range headers {
if len(strings.Split(header, "=")) < 2 {
continue
}
switch strings.ToLower(strings.Split(header, "=")[0]) {
case "username":
username = strings.Split(header, "=")[1]
Expand Down Expand Up @@ -447,6 +450,9 @@ func CheckImap(s *Service, record bool) (*Service, error) {

// check if 'Content-Type' header was defined
for _, header := range headers {
if len(strings.Split(header, "=")) < 2 {
continue
}
switch strings.ToLower(strings.Split(header, "=")[0]) {
case "username":
username = strings.Split(header, "=")[1]
Expand Down Expand Up @@ -547,6 +553,9 @@ func CheckHttp(s *Service, record bool) (*Service, error) {

// check if 'Content-Type' header was defined
for _, header := range headers {
if len(strings.Split(header, "=")) < 2 {
continue
}
if strings.Split(header, "=")[0] == "Content-Type" {
contentType = strings.Split(header, "=")[1]
break
Expand Down

0 comments on commit a2325c2

Please sign in to comment.