Git Product home page Git Product logo

Comments (9)

inexorabletash avatar inexorabletash commented on August 23, 2024

sgtm

from fileapi.

mkruisselbrink avatar mkruisselbrink commented on August 23, 2024

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.

TimothyGu avatar TimothyGu commented on August 23, 2024

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.

annevk avatar annevk commented on August 23, 2024

@bakulf mentions the Entries API as motivation, which seems like it would still be relevant?

from fileapi.

bakulf avatar bakulf commented on August 23, 2024

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.

mkruisselbrink avatar mkruisselbrink commented on August 23, 2024

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.

annevk avatar annevk commented on August 23, 2024

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:

  1. Remove the replace operation from File API and Firefox. And add/change a test.
  2. 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.

andreubotella avatar andreubotella commented on August 23, 2024

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.

domenic avatar domenic commented on August 23, 2024

The WPTs now expect no replacement, but the spec still says replacement must happen. Can we fix the spec?

from fileapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.