Commit 8c5437f7 authored by jianli@chromium.org's avatar jianli@chromium.org
Browse files

Sending a package file using FormData crashes WebKit on Mac.

https://bugs.webkit.org/show_bug.cgi?id=37882

Reviewed by Darin Adler.

Can't add a layout test because DRT does not support generating the file name.

* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::navigateToDifferentDocument):
* platform/network/FormData.cpp:
(WebCore::FormData::appendDOMFormData):
* platform/network/FormData.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent edea4c28
2010-04-27 Jian Li <jianli@chromium.org>
Reviewed by Darin Adler.
Sending a package file using FormData crashes WebKit on Mac.
https://bugs.webkit.org/show_bug.cgi?id=37882
Can't add a layout test because DRT does not support generating the file name.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::submitForm):
(WebCore::FrameLoader::navigateToDifferentDocument):
* platform/network/FormData.cpp:
(WebCore::FormData::appendDOMFormData):
* platform/network/FormData.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
2010-04-27 Adam Barth <abarth@webkit.org>
 
Reviewed by Eric Seidel.
......@@ -504,7 +504,7 @@ void FrameLoader::submitForm(const char* action, const String& url, PassRefPtr<F
m_submittedFormURL = u;
}
formData->generateFiles(m_frame->page()->chrome()->client());
formData->generateFiles(m_frame->document());
if (!m_outgoingReferrer.isEmpty())
frameRequest.resourceRequest().setHTTPReferrer(m_outgoingReferrer);
......@@ -3669,7 +3669,7 @@ void FrameLoader::navigateToDifferentDocument(HistoryItem* item, FrameLoadType l
// If this was a repost that failed the page cache, we might try to repost the form.
NavigationAction action;
if (formData) {
formData->generateFiles(m_frame->page()->chrome()->client());
formData->generateFiles(m_frame->document());
request.setHTTPMethod("POST");
request.setHTTPBody(formData);
......
......@@ -286,13 +286,18 @@ String FormData::flattenToString() const
return Latin1Encoding().decode(bytes.data(), bytes.size());
}
void FormData::generateFiles(ChromeClient* client)
void FormData::generateFiles(Document* document)
{
ASSERT(!m_hasGeneratedFiles);
if (m_hasGeneratedFiles)
return;
Page* page = document->page();
if (!page)
return;
ChromeClient* client = page->chrome()->client();
size_t n = m_elements.size();
for (size_t i = 0; i < n; ++i) {
FormDataElement& e = m_elements[i];
......
......@@ -26,7 +26,6 @@
namespace WebCore {
class ChromeClient;
class DOMFormData;
class Document;
......@@ -101,7 +100,7 @@ public:
const Vector<FormDataElement>& elements() const { return m_elements; }
const Vector<char>& boundary() const { return m_boundary; }
void generateFiles(ChromeClient*);
void generateFiles(Document*);
void removeGeneratedFilesIfNeeded();
bool alwaysStream() const { return m_alwaysStream; }
......
......@@ -496,6 +496,10 @@ void XMLHttpRequest::send(DOMFormData* body, ExceptionCode& ec)
if (m_method != "GET" && m_method != "HEAD" && m_url.protocolInHTTPFamily()) {
m_requestEntityBody = FormData::createMultiPart(*body, document());
// We need to ask the client to provide the generated file names if needed. When FormData fills the element
// for the file, it could set a flag to use the generated file name, i.e. a package file on Mac.
m_requestEntityBody->generateFiles(document());
String contentType = getRequestHeader("Content-Type");
if (contentType.isEmpty()) {
contentType = "multipart/form-data; boundary=";
......
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