Merge pull request #274 from EdisonFu/dev

Add header validation to prevent service panic.
pull/1118/head
Adam 2024-05-10 18:07:54 +01:00 committed by GitHub
commit a2325c24db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 0 deletions

View File

@ -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]
@ -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]
@ -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