Bug 1877792 - Part 1: Change HttpBaseChannel.cpp to allow application/json r=yulia,necko-reviewers,jesup,valentin
Differential Revision: https://phabricator.services.mozilla.com/D155161
This commit is contained in:
@@ -2896,8 +2896,9 @@ nsresult ProcessXCTO(HttpBaseChannel* aChannel, nsIURI* aURI,
|
||||
|
||||
if (aLoadInfo->GetExternalContentPolicyType() ==
|
||||
ExtContentPolicy::TYPE_SCRIPT) {
|
||||
if (nsContentUtils::IsJavascriptMIMEType(
|
||||
NS_ConvertUTF8toUTF16(contentType))) {
|
||||
auto utf16ContentType = NS_ConvertUTF8toUTF16(contentType);
|
||||
if (nsContentUtils::IsJavascriptMIMEType(utf16ContentType) ||
|
||||
nsContentUtils::IsJsonMimeType(utf16ContentType)) {
|
||||
return NS_OK;
|
||||
}
|
||||
ReportMimeTypeMismatch(aChannel, "MimeTypeMismatch2", aURI, contentType,
|
||||
@@ -2945,6 +2946,12 @@ nsresult EnsureMIMEOfScript(HttpBaseChannel* aChannel, nsIURI* aURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (nsContentUtils::IsJsonMimeType(typeString)) {
|
||||
AccumulateCategorical(
|
||||
Telemetry::LABELS_SCRIPT_BLOCK_INCORRECT_MIME_3::text_json);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
switch (aLoadInfo->InternalContentPolicyType()) {
|
||||
case nsIContentPolicy::TYPE_SCRIPT:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SCRIPT:
|
||||
@@ -3139,7 +3146,8 @@ void WarnWrongMIMEOfScript(HttpBaseChannel* aChannel, nsIURI* aURI,
|
||||
nsAutoCString contentType;
|
||||
aResponseHead->ContentType(contentType);
|
||||
NS_ConvertUTF8toUTF16 typeString(contentType);
|
||||
if (!nsContentUtils::IsJavascriptMIMEType(typeString)) {
|
||||
if (!nsContentUtils::IsJavascriptMIMEType(typeString) &&
|
||||
!nsContentUtils::IsJsonMimeType(typeString)) {
|
||||
ReportMimeTypeMismatch(aChannel, "WarnScriptWithWrongMimeType", aURI,
|
||||
contentType, Report::Warning);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user