8 ms·
I agree that this is a good change. Unicode, normalisation, character encodings, etc. should really be handled at the presentation layer, and everything below t
by userbinator 10y ago
I agree that this is a good change. Unicode, normalisation, character encodings, etc. should really be handled at the presentation layer, and everything below that just treats filenames as sequences of bytes, perhaps with one or two exceptions like '/' and \0.
It is interesting to consider a theoretical system in which paths are represented in 0-terminated count-length format (e.g. "foo/bar/baz/myfile.txt" would be "\003foo\003bar\003baz\012myfile.txt\000"), truly allowing any byte in a filesystem node's name, although that might be going a little bit too far.
Things are much easier for the file system if it can just treat names as bags of bytes.
If you're really talking about bags (unordered sets), that would certainly make for an interesting filesystem since filename.txt, filemane.txt, and maletent.fix would all be the same...
- kijeda 10y agoIncidentally, your theoretical system is exactly how the DNS stores domain names.
- saghm 10y ago> If you're really talking about bags (unordered sets), that would certainly make for an interesting filesystem since filename.txt, filemane.txt, and maletent.fix would all be the same... I was thinking the same thing! Although if we're being pedantic, I think "bag" is an "unordered multiset". If it were just a plain unordered set, then "filename.txt" would also be the same as "filenam.txt".
- jfim 10y agoIt's a good idea until you end up with two files that have the "same" name (eg. Amélie.jpg and Amélie.jpg) because one uses decomposed characters (U+0065 and U+0301) and the other one uses a single character (U+00E9). If the difference is not visible in your browser (it shouldn't), try copy-pasting those two filenames in a text editor, one of them is 10 characters long and one of them is 11 characters long.
- jstimpfle 10y agoThe problem exists already on the visual level, since there are pairs of distinct Unicode characters that look very much alike. I think the only thing you can really do about that is restricting to ASCII minus control characters. Probably many programmers would be willing to accept that, but non-technical users not. The next best thing would be to enforce a canonical (code-point?) encoding. But given the complexities of Unicode that will get us only so far...
- ttflee 10y agohttps://turnoff.us/geek/user-space-election/ https://turnoff.us/geek/user-space-election/
- jstimpfle 10y agoThat's not about filenames.
- TazeTSchnitzel 10y ago> The problem exists already on the visual level, since there are pairs of distinct Unicode characters that look very much alike. Yes, but software doesn't consider them equivalent.
- int_19h 10y agoThe software also doesn't consider the two strings given as an example above equivalent, and for the same exact reason: they're sequences of different code points.
- jfim 10y ago> The next best thing would be to enforce a canonical (code-point?) encoding. That's exactly what HFS+ did, and what APFS doesn't.
- Asooka 10y agoIt can get worse - imagine a program that normalizes all paths before handing them off to the fs. Then you go to delete the denormalized file, but it deletes the normalized one. With this change, the only safe way to handle paths would be to NOT normalize at all, but Apple are recommending the exact opposite. I predict a lot of confusion will arise from this change.
- hawski 10y agoAre you also against case sensitive file systems? Otherwise you can end up with two files that have the "same" name - eg. anne.jpg and Anne.jpg). Does normalization cover such a case?
- drdaeman 10y agoI think, the problem with Unicode normalization is, input methods are (well, conceptually, at least) meant to produce text, not binary. If filesystems are using binary data for filenames, there can be a case when is really no way to address a file by typing its name, even if you can type in that language. This isn't an issue for case sensitivity or alike.
- zrm 10y agoPrograms often allow you to type arbitrary binary values using a keyboard, either by holding a keyboard control key and typing the numeric value, or prefixing it with '\'.
- coldtea 10y ago>If filesystems are using binary data for filenames, there can be a case when is really no way to address a file by typing its name, even if you can type in that language You could do that trivially in UNIX since forever.
- drdaeman 10y agoDon't know about other UNIXes, but at least on GNU/Linux, neither IMEs nor filesystems are working with text data - it's all binary strings (with a few restrictions, like unacceptability of NULs). The only place where those binary strings are converted to text is when they're rendered (and this may cause some encoding-related oddities). So, sure one can do that. I would've actually preferred for identifiers to be Unicode text strings.
- snuxoll 10y agoFilesystems themselves treating file names and paths at bits of binary data is the right way to do it, normalization shouldn't be handled directly by the filesystem as it adds complexity and duplication of effort. Ideally, the VFS layer should be handling all this garbage.
- coldtea 10y ago>It's a good idea until you end up with two files that have the "same" name (eg. Amélie.jpg and Amélie.jpg) because one uses decomposed characters (U+0065 and U+0301) and the other one uses a single character (U+00E9). It's still good then. And several systems allow for that just fine, including VMS (uniqueness comes from more than the filename). This is more alike real world folders (which can have identical items, e.g. two copies of the same paper), and is also an excellent way to keep different document versions (keep the name the same, change the date shown).
- ridiculous_fish 10y agoThis feels in some sense like punting the problem. What exactly should the presentation layer do when presenting two files, where the first is named with a precomposed character sequence, and the other has the same name but decomposed? Surface the normalization form the user? Uh, no... The more fundamental question is whether filenames are under control of the user or the system. The answer today is "both": there's blessed paths /System/Library... and non-blessed paths like ~/Documents/Pokemon.txt. Addressing this properly means reifying that distinction: making apps always be explicit about whether they're working with the user's or the filesystem's view of a file. While we're here, why the should the user even have to name every file? Do you name every piece of junk mail on your desk/kitchen island? The ideal for the user is something like tagging, where naming stuff is optional, names are forgiving and perhaps not unique, and files are not restricted to being in one directory. Meanwhile, filesystem names are an implementation detail and the filesystem enjoys Unicode ignorance. Spotlight moved a bit in this direction, but the end goal is still awfully far away.
- Ericson2314 10y agoI'd argue: Use a langauge with generics and make the path type a ((de-)serializable) black box. You still need to make a decision in the end, but are much more free to change it.
- jstimpfle 10y agoThis is not a language issue.
- Ericson2314 10y agoI didn't say it was. I said generics would help one easily switch their choice on the different semantics, not avoid choosing at all.
- jstimpfle 10y agoMany, or most, languages already do that by representing filenames as native strings (which are usually abstract "Unicode" strings).
- silverwind 10y agoThe same goes for case-sensitivity which, unfortunately, they see as a defect. It would be great for portability if APFS would stay case-insensitive like the Unix file systems, e.g. just a dumb layer that reads/writes bytes.
- inimino 10y agoI think you mean case-aware, not case-sensitive. Just bytes like Unix leads to case-sensitive behavior.
- rurban 10y agoNo. Ever heard about http://websec.github.io/unicode-security-guide/ http://websec.github.io/unicode-security-guide/ Identifiers should be identifiable. If a filename is encoded in utf8, it needs to be normalized. To the canonical form of course not the crazy Python 3 or Apple idea of NFD. Which is also slower. If it's encoded as bytes you get garbage in - garbage out. There's much more to consider, but unfortunately you cannot restrict a directory to forbid mixed scripts or confusables. I summarized a few problems at http://perl11.org/blog/unicode-identifiers.html http://perl11.org/blog/unicode-identifiers.html
- jwilk 10y ago> No. Ever heard about http://websec.github.io/unicode-security-guide/ http://websec.github.io/unicode-security-guide/ Which part of it is relevant to pathnames? > To the canonical form of course Do you mean NFC? > not the crazy Python 3 or Apple idea of NFD. In what circumstances does Python 3 normalize pathnames? > If it's encoded as bytes you get garbage in - garbage out. What do you mean by "encoded as bytes"? > http://perl11.org/blog/unicode-identifiers.html http://perl11.org/blog/unicode-identifiers.html This is about programming language identifies, not about pathnames, which are very different beasts.
- rurban 10y ago> Which part of it is relevant to pathnames? All parts regarding identifiers and names, if you see pathnames as publicly identifiable information. See below. > In what circumstances does Python 3 normalize pathnames? None. Python 3 normalizes identifiers to the shorter non-canonical NFKC form. Apple HFS+ normalizes pathnames to the longer D canonical form. Which is faster but takes more space. Usually space is more important than CPU. > What do you mean by "encoded as bytes"? What everyone else means on byte encodings: 1-1 mapping of bytes, without any further knowledge of the encoding. > This is about programming language identifies, not about pathnames, which are very different beasts. Partially. pathnames can also be argued to be identifiers, similar to domain names, email names, user names, language identifiers. Apple does so. Ask plan9 what they think about pathname semantics. Not everyone is in the garbage in - garbage out camp. Many systems do encode pathnames and have character restrictions. Esp. important is the popular / spoof, which people from the garbage camp don't care about. Julia is recent proponent of the garbage camp, btw.
- sametmax 10y agoHow do you normalize arab or chinese in a meaningful way for people speaking these languages ?
- Asooka 10y agoYou don't, there is only one unicode representation of those characters.
- sametmax 10y agoSo what does mac do with those ?
- icebraining 10y agoUse that representation? The problem only happens when there is more than one way to represent the same text.
- sametmax 10y agoOk
- huxley 10y agoInterestingly that created its own annoyances for some since normalization occurs at a different stage. Unicode and UTF-8 unify many Traditional & Simplified Chinese Characters as well as Japanese Kanji and Korean Hanja. There were some extremely angry reactions to Han Character Unification[1], though efforts have been made to overcome many of the initial complaints. [1] "Why Unicode Won’t Work on the Internet: Linguistic, Political, and Technical Limitations" http://www.hastingsresearch.com/net/04-unicode-limitations.shtml http://www.hastingsresearch.com/net/04-unicode-limitations.s...
- jrochkind1 10y agoI don't believe that's literally true, some all legal and correct Japanese unicode sequences will be transformed under at least some of the unicode normalization forms, no?
- quotemstr 10y agoNo good has ever come from allowing BEL and DEL as part of filenames. I'm with David Wheeler: https://www.dwheeler.com/essays/fixing-unix-linux-filenames.html https://www.dwheeler.com/essays/fixing-unix-linux-filenames.... We need to limit filenames for the good of the entire system and the whole community. Filenames as byte strings may sound good, but nobody ever thinks of the costs and the scant benefits.
- YSFEJ4SWJUVU6 10y agoI disagree completely. What we need is to allow even slashes in the file names – not restrict (for what an end user may feel arbitrarily) even more writeable characters off file names, just so we can avoid fixing our replacing our tools or writing one line more in a shell script.
- coldtea 10y agoAny solution you come up with must work with replacing existing software piecemeal, or it's no solution.
- silvestrov 10y ago> Things are much easier for the file system if it can just treat names as bags of bytes. And much, much harder for applications if that "bag of bytes" is an invalid UTF-8 sequence. You will end up with an invalid string (or an exception), and trying to open that file will then fail. I'd really hope that Apple checks that the filenames are valid UTF-8 as they otherwise can end up with very interesting security bugs.
- asdfaoeu 10y agoYou can handle that fine provided you don't assume that. > I'd really hope that Apple checks that the filenames are valid UTF-8 as they otherwise can end up with very interesting security bugs. I think that's a bit pessimistic as Linux has run for year like that without any real issues.
- TazeTSchnitzel 10y ago> And much, much harder for applications if that "bag of bytes" is an invalid UTF-8 sequence. It makes copying-and-pasting filenames as Unicode unreliable, for one thing.
- loeg 10y agoAt least valid utf-8 isn't difficult for a filesystem to enforce.
- hawski 10y agoThis sounds like DJB's Netstring [1]. "hello world!" encoded as "12:hello world!," An empty string as "0:," [1] https://en.wikipedia.org/wiki/Netstring https://en.wikipedia.org/wiki/Netstring
- tyingq 10y ago>perhaps with one or two exceptions like '/' and \0 Aren't colons (:) an issue with MacOS as well? I think Finder and other userspace apps convert them to slashes. I suppose though, there's a case for the filesystem not caring about that.
- infogulch 10y agoIf I were allowed one more distinction I would definitely add utf-8 only.
- emn13 10y agoI'm not so sure: the thing is, those strings are not just a bag of bytes. They have semantics. Is it legal to include bytes that are 0? How about slashes in file names? How about byte sequences that aren't utf8 at all? These things aren't just byte streams, they have semantics. So one risk of treating this as "just bytes" is that bugs will introduce byte sequences that aren't utf8 at all, which will cause other programs to fail, or worse, to "try" and thereby corrupt the data further. Another risk is that since it's supposed to be utf-8, some programs may do canonicalization internally to avoid confusing situations. This may even happen accidentally (though it's not likely): after all, a unicode-processing system could be forgiven for transparently changing canonicalization. But if a program canonicalizes you can now get really weird behavior such as opening a file, then saving it, and ending up with two files that look identical - because the write wrote to a path that was canonicalized. Additionally, even though you can never avoid confusing paths entirely without considering the glyphs rendered, you are losing a very simple check against a fairly large class of errors.
- deleted 10y ago[deleted]