[whatwg] Fakepath revisited

Tab Atkins Jr. jackalmage at gmail.com
Mon Sep 7 08:10:02 PDT 2009


On Mon, Sep 7, 2009 at 3:24 AM, Alex Henrie<alexhenrie24 at gmail.com> wrote:
> Expecting developers to hack out a substring at all will only lead to
> more bad designs. For example, Linux and Mac OS allow filenames to
> contain backslashes. So if the filename was "up\load.txt" then
> foo.value would be "C:\fakepath\up\load.txt" which could easily be
> mistaken for "load.txt". Fakepath will actually encourage developers
> to fall into this trap, which just goes to show that it is not a
> perfect solution.

Well, no, not really.  If they're hacking out a substring, they'll
*hack out a substring*, since the prefix is of a known fixed length.
Just lop off the first 12 characters, and whatever's left is your
filename.  Splitting on "\" is just plain silly in this instance.

~TJ



More information about the whatwg mailing list