summaryrefslogtreecommitdiff
path: root/modules/libjar
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-11-01 20:35:06 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-11-01 20:35:06 +0100
commit370ee3f6e1d1bf6b50d6c6c2b7f176243c35b68d (patch)
tree901210cd14f0d32f354b7ebd2ca9c29a530e4bdf /modules/libjar
parent8aadde266a8d0046f1dd9a715327a7aba84a8178 (diff)
downloaduxp-370ee3f6e1d1bf6b50d6c6c2b7f176243c35b68d.tar.gz
Bug 1460538
Diffstat (limited to 'modules/libjar')
-rw-r--r--modules/libjar/nsJARChannel.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp
index ee60602dae..2f721fa3f5 100644
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -995,6 +995,25 @@ nsJARChannel::OnStartRequest(nsIRequest *req, nsISupports *ctx)
mRequest = req;
nsresult rv = mListener->OnStartRequest(this, mListenerContext);
mRequest = nullptr;
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // Restrict loadable content types.
+ nsAutoCString contentType;
+ GetContentType(contentType);
+ auto contentPolicyType = mLoadInfo->GetExternalContentPolicyType();
+ if (contentType.Equals(APPLICATION_HTTP_INDEX_FORMAT) &&
+ contentPolicyType != nsIContentPolicy::TYPE_DOCUMENT &&
+ contentPolicyType != nsIContentPolicy::TYPE_FETCH) {
+ return NS_ERROR_CORRUPTED_CONTENT;
+ }
+ if (contentPolicyType == nsIContentPolicy::TYPE_STYLESHEET &&
+ !contentType.EqualsLiteral(TEXT_CSS)) {
+ return NS_ERROR_CORRUPTED_CONTENT;
+ }
+ if (contentPolicyType == nsIContentPolicy::TYPE_SCRIPT &&
+ !nsContentUtils::IsJavascriptMIMEType(NS_ConvertUTF8toUTF16(contentType))) {
+ return NS_ERROR_CORRUPTED_CONTENT;
+ }
return rv;
}