Bug 1250148 - FormData should treat empty input type=file as empty string in FormData and as unnamed Blob in HTML submission, r=smaug
This commit is contained in:
@@ -5582,14 +5582,11 @@ HTMLInputElement::SubmitNamesValues(nsFormSubmission* aFormSubmission)
|
||||
const nsTArray<RefPtr<File>>& files = GetFilesInternal();
|
||||
|
||||
for (uint32_t i = 0; i < files.Length(); ++i) {
|
||||
aFormSubmission->AddNameBlobPair(name, files[i]);
|
||||
aFormSubmission->AddNameBlobOrNullPair(name, files[i]);
|
||||
}
|
||||
|
||||
if (files.IsEmpty()) {
|
||||
RefPtr<BlobImpl> blobImpl =
|
||||
new EmptyBlobImpl(NS_LITERAL_STRING("application/octet-stream"));
|
||||
RefPtr<Blob> blob = Blob::Create(OwnerDoc()->GetInnerWindow(), blobImpl);
|
||||
aFormSubmission->AddNameBlobPair(name, blob);
|
||||
aFormSubmission->AddNameBlobOrNullPair(name, nullptr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
Reference in New Issue
Block a user