Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp

Issue 2710033003: Add unknown file size handling in ComplexFormDataBytesConsumer (Closed)
Patch Set: fix Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/filesystem/form-reading-from-file.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp
diff --git a/third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp b/third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp
index 0e36d2d7df54c02992f8a87ea94caded250b6b30..1a655da3914431a89628435f8d33605481c3dbe6 100644
--- a/third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp
+++ b/third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp
@@ -118,17 +118,33 @@ class ComplexFormDataBytesConsumer final : public BytesConsumer {
case FormDataElement::data:
blobData->appendBytes(element.m_data.data(), element.m_data.size());
break;
- case FormDataElement::encodedFile:
+ case FormDataElement::encodedFile: {
+ auto fileLength = element.m_fileLength;
+ if (fileLength < 0) {
+ if (!getFileSize(element.m_filename, fileLength)) {
+ m_formData = nullptr;
+ m_blobBytesConsumer = BytesConsumer::createErrored(
+ Error("Cannot determine a file size"));
+ return;
+ }
+ }
blobData->appendFile(element.m_filename, element.m_fileStart,
- element.m_fileLength,
+ fileLength,
element.m_expectedFileModificationTime);
break;
+ }
case FormDataElement::encodedBlob:
if (element.m_optionalBlobDataHandle)
blobData->appendBlob(element.m_optionalBlobDataHandle, 0,
element.m_optionalBlobDataHandle->size());
break;
case FormDataElement::encodedFileSystemURL:
+ if (element.m_fileLength < 0) {
+ m_formData = nullptr;
+ m_blobBytesConsumer = BytesConsumer::createErrored(
+ Error("Cannot determine a file size"));
+ return;
+ }
blobData->appendFileSystemURL(
element.m_fileSystemURL, element.m_fileStart,
element.m_fileLength, element.m_expectedFileModificationTime);
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/filesystem/form-reading-from-file.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698