mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-12 18:27:32 +09:00
[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)
This commit is contained in:
parent
7f3a7225af
commit
3bcd2ee360
2 changed files with 11 additions and 11 deletions
|
|
@ -639,16 +639,11 @@ DataTransfer::PrincipalMaySetData(const nsAString& aType,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aType.EqualsASCII(kFileMime) ||
|
// Don't allow adding internal types of the form */x-moz-*, but
|
||||||
aType.EqualsASCII(kFilePromiseMime)) {
|
// special-case the url types as they are simple variations of urls.
|
||||||
NS_WARNING("Disallowing adding x-moz-file or x-moz-file-promize types to DataTransfer");
|
if (FindInReadable(NS_LITERAL_STRING(kInternal_Mimetype_Prefix), aType) &&
|
||||||
return false;
|
!StringBeginsWith(aType, NS_LITERAL_STRING("text/x-moz-url"))) {
|
||||||
}
|
NS_WARNING("Disallowing adding requested internal type to DataTransfer");
|
||||||
|
|
||||||
// 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");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,17 @@ interface nsIPrincipal;
|
||||||
|
|
||||||
%{ C++
|
%{ C++
|
||||||
|
|
||||||
|
// Internal formats must have their second part starting with 'x-moz-',
|
||||||
|
// for example text/x-moz-internaltype. These cannot be assigned by
|
||||||
|
// unprivileged content but all other types can.
|
||||||
|
#define kInternal_Mimetype_Prefix "/x-moz-"
|
||||||
|
|
||||||
// these probably shouldn't live here, but in some central repository shared
|
// these probably shouldn't live here, but in some central repository shared
|
||||||
// by the entire app.
|
// by the entire app.
|
||||||
#define kTextMime "text/plain"
|
#define kTextMime "text/plain"
|
||||||
#define kRTFMime "text/rtf"
|
#define kRTFMime "text/rtf"
|
||||||
#define kUnicodeMime "text/unicode"
|
#define kUnicodeMime "text/unicode"
|
||||||
#define kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
|
#define kMozTextInternal "text/x-moz-text-internal" // text data which isn't suppoed to be parsed by other apps.
|
||||||
#define kHTMLMime "text/html"
|
#define kHTMLMime "text/html"
|
||||||
#define kAOLMailMime "AOLMAIL"
|
#define kAOLMailMime "AOLMAIL"
|
||||||
#define kPNGImageMime "image/png"
|
#define kPNGImageMime "image/png"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue