Bug 29000

Summary: Implement HTML5's fakepath
Product: WebKit Reporter: Adam Barth <abarth>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ap, barraclough, commit-queue, dglazkov, eric, ian, mike, mjs, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
work-in-progress
none
patch
none
Patch for landing none

Adam Barth
Reported 2009-09-06 17:02:29 PDT
When you get the value property of an <input type="file">, you're supposed to get C:\fakepath\<filename> instead of just <filename>.
Attachments
work-in-progress (924 bytes, patch)
2009-09-06 17:12 PDT, Adam Barth
no flags
patch (6.20 KB, patch)
2009-09-06 21:09 PDT, Adam Barth
no flags
Patch for landing (6.45 KB, patch)
2010-08-29 17:56 PDT, Adam Barth
no flags
Adam Barth
Comment 1 2009-09-06 17:12:56 PDT
Created attachment 39128 [details] work-in-progress
Adam Barth
Comment 2 2009-09-06 17:14:21 PDT
The code change looks pretty trivial. Any hints about how to write a test?
Adam Barth
Comment 3 2009-09-06 21:09:01 PDT
Created attachment 39130 [details] patch --- 5 files changed, 42 insertions(+), 14 deletions(-)
Eric Seidel (no email)
Comment 4 2009-09-08 09:37:13 PDT
This is about the lamest thing ever. Why oh why would HTML5 spec this?
Eric Seidel (no email)
Comment 5 2009-09-08 09:38:17 PDT
I would like to know what websites our current behavior breaks. Our behavior is much less-lame than HTML5's speced behavior/IE's behavior (assuming HTML5 is matching IE).
Eric Seidel (no email)
Comment 6 2009-09-08 14:46:33 PDT
Comment on attachment 39130 [details] patch I guess I'll r- this based on my above comments. I think the spec should change instead of our implementation, unless there are a list of websites which break due to our (superior) behavior. :)
Sam Weinig
Comment 7 2009-09-08 15:05:13 PDT
I agree with Eric, this is pretty lame. Does anyone know the rationale behind the decision?
Dimitri Glazkov (Google)
Comment 8 2009-09-08 15:08:58 PDT
I think it should be c:\awesomepath. /me ducks.
Gavin Barraclough
Comment 9 2009-09-08 15:21:35 PDT
This is just too painfully idiotic a decision in the spec for words. Please, please, no. eseidel++ for the r-.
Adam Barth
Comment 10 2009-09-08 18:27:35 PDT
The rationale is as follows: 1) Some number of consumer routers won't let you upload new firmware with our current behavior because they try to trim off the non-existent path. Sadly, these sites can't fix the bug without new firmware. 2) IE8 ships with this behavior and ie-team shows little inclination to match our behavior because of (1). See http://blogs.msdn.com/ie/archive/2009/03/20/rtm-platform-changes.aspx Maciej has stated on the HTML WG mailing list that he supports fakepath. There is some amount of debate on this topic in the HTML WG at present. It might make sense to wait and see how the dust settles, or it might sense to help resolve the situation.
Maciej Stachowiak
Comment 11 2009-09-13 14:46:15 PDT
Yes, this behavior is lame. But it seems to be the best available choice given the compatibility, platform-independence and privacy constraints. In particular: 1) Exposing the real path is a privacy/security risk. 2) Exposing Unix-style paths breaks some content, including router Web interfaces and apparently Orkut 3) Exposing bare filenames has some of the same issues as #1. Web developers still have the ability to get the real filename without regexp mangling by using control.fileList[0].fileName. More importantly, from a compatibility perspective, since other browsers are doing this, Web content authors *already* have to be prepared to strip the fakepath prefix. So we're not doing Web developers any favors by omitting it. And finally, while the lameness of this compatibility hack is very visible, it's hardly the lamest compatibility hack in the Web platform. Take a look at WebKit's "quirky em" unites or how parsing works when a <form> is misnested inside table structure. This hack just seems gross because it is easy to understand its wrongness without being an expert in the relevant part of the code.
Maciej Stachowiak
Comment 12 2009-09-13 14:47:55 PDT
The upshot of my comments is, I think we should just bite the pillow and get this change over with.
Adam Barth
Comment 13 2010-08-14 23:27:08 PDT
Comment on attachment 39130 [details] patch Here we are a year later and the spec hasn't changed. I think we should reconsider this path.
Eric Seidel (no email)
Comment 14 2010-08-15 07:52:41 PDT
I foresee in the future we'll add a new property just to get the real name. This seems to run against Darin Adler's "The future is bigger than the past" argument in other bugs. I have a lot of faith in Hixie, but how many pages are we talking about? The sad thing is that it seems other browsers have done this too, which means we need to. We were just all stupid as a community to cave in the first place.
Ian 'Hixie' Hickson
Comment 15 2010-08-15 09:16:03 PDT
Believe me, I wouldn't have specced this if it wasn't a de facto standard backed with compatibility arguments. We already have an API for getting the name accurately: HTMLInputElement.files[0].name
Darin Adler
Comment 16 2010-08-29 11:39:05 PDT
Comment on attachment 39130 [details] patch > + if (!m_fileList->isEmpty()) { > + String value = "C:\\fakepath\\"; > + value.append(m_fileList->item(0)->fileName()); > + return value; > + } This can be written just with the plus operator: if (!m_fileList->isEmpty()) return C:\\fakepath\\" + m_fileList->item(0)->fileName(); I think that's more pleasant. But also, I think that the fakepath will be mysterious without a comment.
Adam Barth
Comment 17 2010-08-29 17:56:45 PDT
Created attachment 65867 [details] Patch for landing
WebKit Commit Bot
Comment 18 2010-08-29 18:16:42 PDT
Comment on attachment 65867 [details] Patch for landing Clearing flags on attachment: 65867 Committed r66343: <http://trac.webkit.org/changeset/66343>
WebKit Commit Bot
Comment 19 2010-08-29 18:16:48 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 20 2010-08-29 18:45:58 PDT
http://trac.webkit.org/changeset/66343 might have broken Qt Linux Release
Alexey Proskuryakov
Comment 21 2010-08-30 09:50:24 PDT
-PASS fileInput.value is "DRTFakeFile" +FAIL fileInput.value should be DRTFakeFile. Was C:\fakepath\DRTFakeFile. These should be PASS, not FAIL.
Adam Barth
Comment 22 2010-08-30 10:36:58 PDT
> These should be PASS, not FAIL. Ok.
Adam Barth
Comment 23 2010-08-30 12:15:49 PDT
> These should be PASS, not FAIL. See Bug 44882.
Note You need to log in before you can comment on or make changes to this bug.