Live data from Hacker News

APFS is not safe to use with names which have Unicode normalisation issues

eclecticlight.co

111–120 of 191 posts

Re: APFS is not safe to use with names which have Unicode normalisation issues

#111
post #30

Personally I think the current Normalisation Form D is awful, storing an ü as two characters is really annoying and even bash can't really deal with it in the version Apple uses. I really hope APFS will fix this. But we'll see.

It's awful in great part because common input modes produce something close to NFC.

Apple could of course change their keyboard layouts to produce something close to NFD. (OS X has always allowed keys to produce multi-character results.)

Re: APFS is not safe to use with names which have Unicode normalisation issues

#112

Earlier quoted context omitted.

> Should filesystems be making up for our Unicode shortcomings? Absolutely, yes. File names are text by their very definition; that we've been treating them as "bags of bytes" is a historical tragedy. At the very least, file names need to be displayed, as text, to the user, so they should be stored as text , that is in some well-defined encoding, and yes, it should be the job of the filesystem driver / kernel to enfo…

But what is text? Not everyone wants to use unicode. It is dependent of the platform, the region, the OS and on many other different things like LC_* variables on linux. Why should a filesystem depend on those too?

> and on many other different things like LC_ variables on linux.*

The point is that it doesn't need to be. I would entertain that not everyone might not want to use Unicode: in that case, the FS should still have a well-defined encoding, such that I can still arrive at a string to display to the user. The point is not that "Unicode is best" but that storing file names as "bags of bytes" is incredibly user unfriendly, and there needs to be a straightforward, no bullshit method to display and transmit the names of files.

But I would also argue that Unicode is the best we've got presently, and it would be pragmatic for a filesystem to simply adopt it outright. It's overwhelmingly the dominant character set in use today, especially if you ignore deprecated junk that Unicode is a strict superset of.

Re: APFS is not safe to use with names which have Unicode normalisation issues

#113

Wait why is a file name a sequence of bytes? Why is it not a sequence of bytes that form a valid string in some encoding, so that you can just refuse some file names? Who refuses invalid characters such as invisible characters or "/"? Would not the same place be a good place to refuse anything that doesn't normalize to the same byte sequence, or an even stricter subset?

Supporting more than one encoding requires knowing what that is, and apps and APIs are very bad at keeping track of that. Which is why only Unicode in some UTF makes sense.

ZFS allows you to store non-UTF-8 if you like, but for all valid UTF-8 it implements normalization-preserving/insensitive behavior, which is the best possible compromise (IMO).

Re: APFS is not safe to use with names which have Unicode normalisation issues

#114

Earlier quoted context omitted.

"without warning"? Not really. This has been discussed to death on ATP last year. Also, in regards to the headline, there are tens or maybe over a hundred million non-english speakers using iOS already running APFS...

Did anyone mention normalization-preserving/normalization-insensitive behavior? That's what ZFS does, and it's great!

> Did anyone mention normalization-preserving/normalization-insensitive behavior?

You did, 11 times so far this thread. I counted.

Re: APFS is not safe to use with names which have Unicode normalisation issues

#115
post #3
post #2

Would be interesting to know why Apple made the decision not to normalize on a file system level then. Just an argument based on separation of concerns?

Normalizing on the file system level in the past was a mistake. Normalizing Unicode is not an easy task, it belongs into userspace and not into a kernel driver. Other systems consider filename a string of octets and interpretation what these octets mean is left for userspace to decide. For Linus Torvalds colorful opinions on HFS+, see here: https://plus.google.com/+JunioCHamano/posts/1Bpaj3e3Rru (in the comments).

Normalization on CREATE was the mistake.

ZFS does normalization on LOOKUP. This is much better, as it preserves whatever form you used, but is normalization-form insensitive, which is precisely what users need (and would want, if only they could be expected to understand what the heck is going on!).

Re: APFS is not safe to use with names which have Unicode normalisation issues

#116
post #80

Earlier quoted context omitted.

> Again, the article made a huge sweeping claim without supporting it. Looks to me like the article made claims and backed them up with examples and screenshots. Rather than saying the article is wrong, can you demonstrate /why/ it is wrong? Using its examples and concerns (Finder, console, and scripts)?

> Rather than saying the article is wrong, can you demonstrate /why/ it is wrong? I think you might to re-read my entire comment: note that I'm not arguing that the technical details are wrong, only that they're insufficient to support the huge “APFS is unusable” conclusion. As previously noted, Windows and Linux work the same way and they are used by more people in individual non-English locales than the total numbe…

The issue isn't a "bag-of-bytes" filename model. The issue is a "bag-of-bytes" filename model combined with an inconsistent normalization scheme.

It's not a problem on Windows or Linux filesystems because Windows and Linux don't provide a half-assed normalization scheme that lets me fairly easily create files that can't be accessed. If the Cocoa libraries did no normalization, then the resulting behavior might be obnoxious from a human-interface perspective, but I don't think the article would describe it as "little short of catastrophic".

I'm sitting here on my US English keyboard typing scancodes that look just like they did in 1990, so I'm not the best authority on how big of a problem it really is, but I'd guess it's going to result in a lot of bugs. Anyone who's ever tried to use a Mac with a case-sensitive HFS+ partition should be able to tell you that programmers can't even "normalize" their filenames consistently strictly within their native language.

Re: APFS is not safe to use with names which have Unicode normalisation issues

#117
post #7

To be honest, I blame Unicode. Why allow different representations for the same character, and then provide a normalized form anyway, except it's not one normalized form but several? Sounds like job security to me.

It's not Unicode's fault. Unicode took a terrible situation (lots of complex scripts) and did the best it could to give us a unified way of representing text in all scripts.

Re: APFS is not safe to use with names which have Unicode normalisation issues

#118
post #105

Earlier quoted context omitted.

Almost! But not quite: it aliases some possible filenames, though only they are valid UTF-8 encodings (or UTF-16 say, if one did this on Windows). In particular, it prevents the existence of two files with equivalent names.

Interesting, so it recognizes different encodings of the same Unicode code points?

Yes. Well, it recognizes different forms of the same characters. The encoding is and must be UTF-8.

Re: APFS is not safe to use with names which have Unicode normalisation issues

#119

Earlier quoted context omitted.

Did anyone mention normalization-preserving/normalization-insensitive behavior? That's what ZFS does, and it's great!

> Did anyone mention normalization-preserving/normalization-insensitive behavior? You did, 11 times so far this thread. I counted.

Only? Hold my beer..

Re: APFS is not safe to use with names which have Unicode normalisation issues

#120
post #106
post #105

Earlier quoted context omitted.

Interesting, so it recognizes different encodings of the same Unicode code points?

Or does it just map code points that are identical to each other?

Yes. But only for the purpose of string comparison and hashing (ZFS hashes directories for fast lookups).
Post reply on HN