From fd798a0d2d220221c24b37c71fb45235df8eb374 Mon Sep 17 00:00:00 2001 From: Michael Ibragimchayev Date: Thu, 21 Jan 2021 14:47:45 -0500 Subject: [PATCH] add in support for domains without contentType defined. --- yurllib/aasa.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/yurllib/aasa.go b/yurllib/aasa.go index abeff87..b5f3d6c 100644 --- a/yurllib/aasa.go +++ b/yurllib/aasa.go @@ -50,9 +50,16 @@ func CheckDomain(inputURL string, bundleIdentifier string, teamIdentifier string output = append(output, fmt.Sprintf("Content-type: \t\t\t %s \n", contentType)) - isEncryptedMimeType := contentType[0] == "application/pkcs7-mime" - isJSONMimeType := contentType[0] == "application/json" || contentType[0] == "text/json" || contentType[0] == "text/plain" || strings.Contains(contentType[0], "application/json") || contentType[0] == "application/octet-stream" - isJSONTypeOK := allowUnencrypted && isJSONMimeType // Only ok if both the "allow" flag is true, and... it's a valid type. + isEncryptedMimeType := false + isJSONTypeOK := false + + if len(contentType) > 0 { + isEncryptedMimeType = contentType[0] == "application/pkcs7-mime" + isJSONMimeType := contentType[0] == "application/json" || contentType[0] == "text/json" || contentType[0] == "text/plain" || strings.Contains(contentType[0], "application/json") || contentType[0] == "application/octet-stream" + isJSONTypeOK = allowUnencrypted && isJSONMimeType // Only ok if both the "allow" flag is true, and... it's a valid type. + } else { + isJSONTypeOK = true + } result, err := ioutil.ReadAll(rawResult.Body) if err != nil { @@ -62,7 +69,7 @@ func CheckDomain(inputURL string, bundleIdentifier string, teamIdentifier string } if !isEncryptedMimeType && !isJSONTypeOK { - output = append(output, fmt.Sprintf("Invalid content-type: \t\t %s \n", contentType[0])) + output = append(output, fmt.Sprintf("Invalid content-type: \t\t %s \n", contentType)) output = append(output, fmt.Sprint("\nIf you believe this error is invalid, please open an issue on github or email support@chayev.com and we will investigate.")) return output }