Comments (9)
sgtm
from fileapi.
Looking at https://wpt.fyi/results/FileAPI/file/File-constructor.html?label=experimental&label=master&aligned it appears that "Neither Chrome nor Gecko seems to implement it." is perhaps no longer true? It seems that now Gecko is the odd one out and actually does implement what the current spec says...
from fileapi.
Gecko implemented this in https://bugzilla.mozilla.org/show_bug.cgi?id=1321534 (2016). The actual discussion thread is https://lists.w3.org/Archives/Public/public-webapps/2013JulSep/0379.html, where there was quite a bit of back and forth.
FWIW, Servo implements it too with a reference to this issue.
from fileapi.
@bakulf mentions the Entries API as motivation, which seems like it would still be relevant?
from fileapi.
In the Entries API, a name cannot contain '/' (https://wicg.github.io/entries-api/#names-paths). That spec uses '/' as directory separator here: https://wicg.github.io/entries-api/#evaluate-a-path
We should try to keep the File API compatible with the Entries API.
from fileapi.
I see, it's unfortunate Firefox implemented this change without noticing that this open issue existed, but I guess ultimately that is on us spec editors for not clearly marking these things in the spec.
I'm not sure what the Entries API has to do with this. The Entries API does not consume File objects, it produces them. And when it produces them it doesn't do so by invoking the File constructor. The logic here only effect File objects created by javascript it seems completely irrelevant what the Entries API does (well, not irrelevant, it is good to be consistent. But that has nothing to do with being compatible).
(also I might be missing something/not finding the right message, but I don't see anything in that discussion thread specifically related to replacing '/' with ':'?)
If we do actually want to disallow '/' in the name
attribute of a script created File
, I'm not sure why replacing it with ':' makes sense. Wouldn't it make more sense to just reject entirely?
Also, non-traditional file systems, like for example Google Drive, do allow '/' in file names. And it's not immediately obvious to me why we would need to stop them from creating File objects with those names. Different platforms/file systems have different limitations, but we're not limiting File objects to the strictest possible subset of filenames (8.3 filenames only anyone?)
from fileapi.
Replacing rather than throwing does seem bad and Entries API does indeed only produce File objects, it doesn't appear to consume them. Entries API does appear to define a model for files in https://wicg.github.io/entries-api/#names-paths onward and that does conflict with allowing various code points in the name, including /
. And its processing model does seem to get confused if a name with /
would appear as it deals with paths as single strings.
Looking at this I think a reasonable outcome would be:
- Remove the replace operation from File API and Firefox. And add/change a test.
- File an issue against Entries API to ensure it's model for files is aligned with File API. We shouldn't have multiple conflicting models of what files are in the web platform.
from fileapi.
There's also the issue that HTML specifies that filenames for <input type="file">
must not contain path components separated by '\\'
, but it says nothing about '/'
. I don't think this is an issue that any of the algorithms in HTML would choke on (unless you count input.value
being "C:\\fakepath\\" + filename
), but in the interest of consistency, if the File constructor throws on one, it should also throw on the other.
from fileapi.
The WPTs now expect no replacement, but the spec still says replacement must happen. Can we fix the spec?
from fileapi.
Related Issues (20)
- TPAC planning and specification status report HOT 2
- Async factory methods for Blob and File HOT 4
- Support using AbortController with FileAPI HOT 6
- Specify how filenames from the OS map to File's `name` property HOT 2
- features request:add SynFileReader for Avoid Callback Hell Programming from FileReader HOT 1
- Clarify UUID version HOT 1
- Align with ReadableStream changes HOT 1
- Issues with MIME types HOT 2
- Consider allowing re-reads after snapshot state change for applications loaded from file: URIs
- Disparity in `loadend` event dispatch between spec, implementation & tests HOT 4
- blob: slice() without valid content type yields unexpected results HOT 2
- TPAC 2022 status report HOT 1
- Consider adding `blob.dataUrl()` method, or some other analogue to `readAsDataURL` HOT 9
- Broken references in File API
- Byte stream support for `stream()`?
- Function signature change: reading all bytes from a stream
- createObjectURL with ReadableStream HOT 2
- Don't export "resolve" HOT 4
- Proposal: Add a capability to create a Blob URL with a unique (non-opaque) origin HOT 19
- Specify actual byte reading algorithm for Blob.stream()
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fileapi.