W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2009

[whatwg] Fakepath revisited

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Mon, 7 Sep 2009 10:10:02 -0500
Message-ID: <dd0fbad0909070810x35870316u8d622a8b5f808b26@mail.gmail.com>
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
Received on Monday, 7 September 2009 08:10:02 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:52 UTC