summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-02-10 22:21:40 +0000
committerMoonchild <moonchild@palemoon.org>2022-02-10 22:21:40 +0000
commitf19cbb3f9e06e08a09dc4107ba0f6d3eea267d30 (patch)
treede0244a42b3307a8011c119be55b56d3a8300f15 /dom
parent3c32487efff48f2bd777bb73fdacca9c05d5b213 (diff)
downloadaura-central-f19cbb3f9e06e08a09dc4107ba0f6d3eea267d30.tar.gz
[DOM] Don't allow internal MIME types to be assigned to DataTransfer
We already blocked x-moz-file(-promise) and x-moz-place* but of course people would find ways to abuse other internal types. This change now blocks everything except x-moz-url types which are harmless. (i.e. whitelist instead of blacklist)
Diffstat (limited to 'dom')
-rw-r--r--dom/events/DataTransfer.cpp15
1 files changed, 5 insertions, 10 deletions
diff --git a/dom/events/DataTransfer.cpp b/dom/events/DataTransfer.cpp
index 5e7d477df..3a3f5464d 100644
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -639,16 +639,11 @@ DataTransfer::PrincipalMaySetData(const nsAString& aType,
return false;
}
- if (aType.EqualsASCII(kFileMime) ||
- aType.EqualsASCII(kFilePromiseMime)) {
- NS_WARNING("Disallowing adding x-moz-file or x-moz-file-promize types to DataTransfer");
- return false;
- }
-
- // Disallow content from creating x-moz-place flavors, so that it cannot
- // create fake Places smart queries exposing user data.
- if (StringBeginsWith(aType, NS_LITERAL_STRING("text/x-moz-place"))) {
- NS_WARNING("Disallowing adding moz-place types to DataTransfer");
+ // Don't allow adding internal types of the form */x-moz-*, but
+ // special-case the url types as they are simple variations of urls.
+ if (FindInReadable(NS_LITERAL_STRING(kInternal_Mimetype_Prefix), aType) &&
+ !StringBeginsWith(aType, NS_LITERAL_STRING("text/x-moz-url"))) {
+ NS_WARNING("Disallowing adding requested internal type to DataTransfer");
return false;
}
}