mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1431095 - Change Content-Type-Options: nosniff allowed script MIME types to match the spec. r=ckerschb
--HG-- extra : rebase_source : e4047e619b88bbb025f3eab27e8e1a826a9429b7
This commit is contained in:
parent
dc9e1f8ab9
commit
db56d2ee65
@ -4308,20 +4308,6 @@ nsContentUtils::IsChildOfSameType(nsIDocument* aDoc)
|
||||
return sameTypeParent != nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::IsScriptType(const nsACString& aContentType)
|
||||
{
|
||||
// NOTE: if you add a type here, add it to the CONTENTDLF_CATEGORIES
|
||||
// define in nsContentDLF.h as well.
|
||||
return aContentType.EqualsLiteral(APPLICATION_JAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_XJAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(TEXT_ECMASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_ECMASCRIPT) ||
|
||||
aContentType.EqualsLiteral(TEXT_JAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_JSON) ||
|
||||
aContentType.EqualsLiteral(TEXT_JSON);
|
||||
}
|
||||
|
||||
bool
|
||||
nsContentUtils::IsPlainTextType(const nsACString& aContentType)
|
||||
{
|
||||
@ -4331,7 +4317,13 @@ nsContentUtils::IsPlainTextType(const nsACString& aContentType)
|
||||
aContentType.EqualsLiteral(TEXT_CSS) ||
|
||||
aContentType.EqualsLiteral(TEXT_CACHE_MANIFEST) ||
|
||||
aContentType.EqualsLiteral(TEXT_VTT) ||
|
||||
IsScriptType(aContentType);
|
||||
aContentType.EqualsLiteral(APPLICATION_JAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_XJAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(TEXT_ECMASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_ECMASCRIPT) ||
|
||||
aContentType.EqualsLiteral(TEXT_JAVASCRIPT) ||
|
||||
aContentType.EqualsLiteral(APPLICATION_JSON) ||
|
||||
aContentType.EqualsLiteral(TEXT_JSON);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1232,11 +1232,6 @@ public:
|
||||
*/
|
||||
static bool IsChildOfSameType(nsIDocument* aDoc);
|
||||
|
||||
/**
|
||||
* Returns true if the content-type is any of the supported script types.
|
||||
*/
|
||||
static bool IsScriptType(const nsACString& aContentType);
|
||||
|
||||
/**
|
||||
* Returns true if the content-type will be rendered as plain-text.
|
||||
*/
|
||||
|
@ -1299,7 +1299,7 @@ ProcessXCTO(nsIURI* aURI, nsHttpResponseHead* aResponseHead, nsILoadInfo* aLoadI
|
||||
}
|
||||
|
||||
if (aLoadInfo->GetExternalContentPolicyType() == nsIContentPolicy::TYPE_SCRIPT) {
|
||||
if (nsContentUtils::IsScriptType(contentType)) {
|
||||
if (nsContentUtils::IsJavascriptMIMEType(NS_ConvertUTF8toUTF16(contentType))) {
|
||||
return NS_OK;
|
||||
}
|
||||
ReportTypeBlocking(aURI, aLoadInfo, "MimeTypeMismatch");
|
||||
|
@ -4,8 +4,8 @@
|
||||
<script>
|
||||
var log = function() {}, // see comment below
|
||||
p = function() {}, // see comment below
|
||||
fails = [null, "", "x", "x/x"],
|
||||
passes = ["text/javascript", "text/ecmascript", "text/ecmascript;blah"]
|
||||
fails = [null, "", "x", "x/x", "text/json"],
|
||||
passes = ["text/javascript", "text/ecmascript", "text/ecmascript;blah", "text/javascript1.0"]
|
||||
|
||||
// Ideally we'd also check whether the scripts in fact execute, but that would involve
|
||||
// timers and might get a bit racy without cross-browser support for the execute events.
|
||||
|
Loading…
Reference in New Issue
Block a user