backport Bug 1502599: XHR should allow just "GET" method for blob URLs, r=smaug

This commit is contained in:
roytam1 2021-12-14 22:48:16 +08:00
commit 6477ec9b56

View file

@ -86,6 +86,7 @@
#include "mozilla/Preferences.h"
#include "private/pprio.h"
#include "XMLHttpRequestUpload.h"
#include "nsHostObjectProtocolHandler.h"
using namespace mozilla::net;
@ -2880,6 +2881,11 @@ XMLHttpRequestMainThread::SendInternal(const RequestBodyBase* aBody)
return NS_ERROR_DOM_NETWORK_ERR;
}
// non-GET requests aren't allowed for blob.
if (IsBlobURI(mRequestURL) && !mRequestMethod.EqualsLiteral("GET")) {
return NS_ERROR_DOM_NETWORK_ERR;
}
PopulateNetworkInterfaceId();
// XXX We should probably send a warning to the JS console