Commit 0689f941 authored by Marijn Kruisselbrink's avatar Marijn Kruisselbrink Committed by Commit Bot

Check types before checking body size in InspectorNetworkAgent code.

EncodedFormData::SizeInBytes doesn't support all possible types (in
particular it DCHECKs on kDataPipe), so by swapping the order of checks
we make sure things actually work correctly.

On of several changes towards making uploading blobs with network service work.

Bug: 821878
Change-Id: I64313bcc390756de6ad0be091d0ab32e9b78ae44
Reviewed-on: https://chromium-review.googlesource.com/962833Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543207}
parent 88e00e57
......@@ -448,13 +448,17 @@ static bool FormDataToString(scoped_refptr<EncodedFormData> body,
*content = "";
if (!body || body->IsEmpty())
return false;
if (max_body_size != 0 && body->SizeInBytes() > max_body_size)
return true;
// SizeInBytes below doesn't support all element types, so first check if all
// the body elements are of the right type.
for (const auto& element : body->Elements()) {
if (element.type_ != FormDataElement::kData)
return true;
}
if (max_body_size != 0 && body->SizeInBytes() > max_body_size)
return true;
Vector<char> bytes;
body->Flatten(bytes);
*content = String::FromUTF8WithLatin1Fallback(bytes.data(), bytes.size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment