Skip to content

Commit

Permalink
add in support for domains without contentType defined.
Browse files Browse the repository at this point in the history
  • Loading branch information
chayev committed Jan 22, 2021
1 parent 7d43c71 commit fd798a0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions yurllib/aasa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down

0 comments on commit fd798a0

Please sign in to comment.