Open madig opened 2 years ago
Also, I can create a file named "hello.com1.txt" on my Windows 10 21H2 (and some Windows XP) PC. Where does the
Use period as a delimiter to split name into parts.
part in the spec come from? Is it maybe enough to just look at the string as a whole?
Edit: I can't create a file named "com1 " (note the space) but "com1 .txt" is fine. userNameToFileName
won't prevent the former.
Also, the spec says that e.g. "C:" is a reserved file name, but I don't think this needs to be checked, because the colon is already unconditionally replaced in the first step.
The following links say somewhat inconsistent things about what is illegal and reserved:
I also found that I can't name things e.g. "com0.txt" on my Windows machine in Explorer, but can in PowerShell. Hm.
So, maybe the algorithm needs to be changed a bit. If we say we support (V|ex)FAT, NTFS, HFS(+) and any POSIXy filesystem, as the 255 character limit suggests, and none of the old DOS crap, it could instead ensure:
[':', '?', '"', '(', ')', '[', ']', '*', '/', '\\', '+', '<', '>', '|']
(Not sure why "()" are disallowed by the spec?)["con", "prn", "aux", "nul", "com1", "com2", "com3", "com4", "com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3", "lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9"]
(Note that this means "com1.txt" and "com1" but not "hello.com1.txt" and "hello.com1")How'd that sound?
That sounds/seems fine. I would venture to guess that the last item (Trailing periods and spaces) may be a breaking change. For the (
& )
rule; I'm not sure why they aren't allowed, but I would not remove them from that list; not allowing them hasn't been an issue so far, no need to touch want isn't broken.
(@madig I'm assuming you may PR this change?)
I started something at https://github.com/fonttools/fonttools/pull/2506 -- if that's ok to merge, I can expand the spec.
That PR looks good to merge, but I'll let others chime in there. Thank you for doing the spec update!
Leftover todo after merged #204:
According to https://docs.microsoft.com/en-gb/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN#naming-conventions, the reserved file names are:
Should the spec be upated to contain only those? Note how "CLOCK$" and drive letters aren't mentioned (colons are replaced already anyway).
There's also https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/b04c3bd0-79dc-4e58-b8ed-74f19fc2ea0a. Not sure they should be reserved names as well?