WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
111687
FormData should allow setting filename to empty
https://bugs.webkit.org/show_bug.cgi?id=111687
Summary
FormData should allow setting filename to empty
Alexey Proskuryakov
Reported
2013-03-06 22:58:47 PST
Per XMLHttpRequest spec, empty filename should be supported: - Set its name to name. - Set its value to value. - Set its type to "text" if value is a string and "file" if it is a Blob. - If its type is "file" set its filename to "blob". - If its type is "file" and value is a File whose name attribute is not the empty string, set entry's filename to the attribute's value. - If the filename parameter is not omitted set entry's filename to filename. This makes sense, because empty form type=file controls are sent as files with empty name by normal form submission. Also, this would be helpful for WebKit, because currently we have to simulate empty path with a File that has an empty path internally, which is an unfortunate hack. Using a blob would be nicer.
Attachments
proposed fix
(10.65 KB, patch)
2013-03-06 23:12 PST
,
Alexey Proskuryakov
beidson
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Alexey Proskuryakov
Comment 1
2013-03-06 23:12:07 PST
Created
attachment 191928
[details]
proposed fix
Victor Costan
Comment 2
2013-03-06 23:21:46 PST
Thank you for cc-ing me on this! I will use the test structure you set up there for the tests in 111380.
Alexey Proskuryakov
Comment 3
2013-03-06 23:31:36 PST
> we have to simulate empty path with a File that has an empty path
This wasn't very clear, but the patch should speak louder than words.
Benjamin Poulain
Comment 4
2013-03-07 01:03:15 PST
Comment on
attachment 191928
[details]
proposed fix View in context:
https://bugs.webkit.org/attachment.cgi?id=191928&action=review
> Source/WebCore/html/FileInputType.cpp:158 > + encoding.appendBlob(element()->name(), BlobBuilder().getBlob("application/octet-stream"), emptyString());
ASCIILiteral("application/octet-stream")?
Victor Costan
Comment 5
2013-03-07 08:44:03 PST
Since BlobBuilder was deprecated in the spec, would it simplify the code if its implementation was moved into the Blob constructor? I'm not saying that this should happen here, BTW. I'm mostly asking because I'd be interested in taking up the cleanup work, to learn more about the codebase.
Alexey Proskuryakov
Comment 6
2013-03-07 10:06:44 PST
> ASCIILiteral("application/octet-stream")?
Can do.
> Since BlobBuilder was deprecated in the spec, would it simplify the code if its implementation was moved into the Blob constructor?
Possibly. Currently, BlobBuilder interface is a bit too large to include into Blob, and it's oriented towards incremental building. But perhaps most of that is not needed any more, and can be simplified. In this patch, I could have avoided using BlobBuilder, although I'm not sure if that's a win: OwnPtr<BlobData> emptyBlobData = BlobData::create(); emptyBlobData->setContentType(ASCIILiteral("application/octet-stream")); encoding.appendBlob(element()->name(), Blob::create(emptyBlobData.release(), 0), emptyString());
Brady Eidson
Comment 7
2013-03-07 10:19:30 PST
Comment on
attachment 191928
[details]
proposed fix R+ with ASCIILiteral fix
Victor Costan
Comment 8
2013-03-07 10:25:28 PST
I also don't think removing the BlobBuilder reference is a win. If that cleanup is ever desirable, I'd like to have a helper that makes this task a one-liner.
Alexey Proskuryakov
Comment 9
2013-03-07 10:27:36 PST
Committed <
http://trac.webkit.org/changeset/145097
>.
WebKit Review Bot
Comment 10
2013-03-07 12:29:34 PST
Re-opened since this is blocked by
bug 111765
Adam Barth
Comment 11
2013-03-07 12:29:55 PST
ap and I discussed this topic on #webkit. We're going to roll out the change for the time being. I'm going to remove the ASSERT from the Chromium code and then re-land this patch.
Adam Barth
Comment 12
2013-03-07 13:31:38 PST
Chromium side-change is under review at
https://codereview.chromium.org/12633004/
Alexey Proskuryakov
Comment 13
2013-03-07 14:53:19 PST
OK, so turns out that old and new code is equally wrong in this regard, but old code did not have an assertion to catch that. What happens is that the object created here is deleted earlier than it should be - it is owned by DOMFormData, and that's destroyed at the end of FormSubmission::create(). So, a Blob or a File becomes unregistered in blob registry, and cannot be used when actually building form data stream in another process. We should obviously keep uploaded objects alive while form submission takes place. Anyway, I'm going to re-land the parts of this patch that actually implement what bug title says. This additional fix should be made separately.
Adam Barth
Comment 14
2013-03-07 14:59:58 PST
> Anyway, I'm going to re-land the parts of this patch that actually implement what bug title says. This additional fix should be made separately.
It's unclear to me whether I should land <
https://codereview.chromium.org/12633004/
>.
Alexey Proskuryakov
Comment 15
2013-03-07 15:05:24 PST
Re-landed safe parts in <
http://trac.webkit.org/changeset/145142
>. Filed
bug 111778
to track the pre-existing issue.
Alexey Proskuryakov
Comment 16
2013-03-07 15:05:48 PST
> It's unclear to me whether I should land <
https://codereview.chromium.org/12633004/
>.
I don't think that it should be landed any more.
Adam Barth
Comment 17
2013-03-07 15:07:57 PST
> I don't think that it should be landed any more.
Thanks. I've marked the code review as closed.
Alexey Proskuryakov
Comment 18
2013-03-07 15:09:55 PST
I appreciate your help dealing with this issue, and Michael's insight into the reasons of the assertion!
Michael Nordman
Comment 19
2013-03-07 15:11:02 PST
Fyi: I've been working towards fixing that for a while now. Its not just a problem with FormData. The changes I've got are simple enough but landing it is troublesome because I'm changing what the blob identifiers identify and I haven't come up with a great way to do that given the chromium/webkit split svn personality. webcore changes -
https://codereview.chromium.org/11192017/
chromium changes -
https://codereview.chromium.org/11410019/
I have been whittling down on the size of these changes by landing smaller parts independently. This small change awaiting review is a part of that...
https://bugs.webkit.org/show_bug.cgi?id=108851
... but there come the time to change what the identifier identifies and I don't know how to cross that chasm quite yet.
Michael Nordman
Comment 20
2013-03-07 16:14:03 PST
Here's the umbrella bug open for that.
https://bugs.webkit.org/show_bug.cgi?id=108733
Dean Jackson
Comment 21
2013-03-07 16:33:28 PST
http/tests/misc/empty-file-formdata.html is failing on WK1 Mac after this
http://build.webkit.org/results/Apple%20MountainLion%20Release%20WK1%20(Tests)/r145143%20(7681)/results.html
Alexey Proskuryakov
Comment 22
2013-03-07 17:19:16 PST
Accidental commit of local changes, fixed that now.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug