File names and paths test values
Names a file system rejects, alters, or reads differently than the user meant. 12 values, each with what it breaks and what a correct application does instead.
Type them one at a time with AltShiftN
in the palette, or take them all into a script with nkb emit filenames-paths.
Reserved device name
filenames-paths/reserved-con
CON
CON
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- A device name reserved by one operating system; a file with this name cannot be created and the failure often surfaces as a generic error.
- What a correct application does
- Rejected at input with a message naming the reserved word, not at write time.
Trailing dot
filenames-paths/trailing-dot
report.
report.
- 7 graphemes
- 7 code points
- 7 bytes
- 7 UTF-16 units
- What it breaks
- Trailing dots are silently removed by some file systems, so the stored name differs from the requested one.
- What a correct application does
- Rejected, or normalised visibly so the user sees the name that will be used.
Trailing space in a file name
filenames-paths/trailing-space-name
report
report\u0020
- ends with a space
- 7 graphemes
- 7 code points
- 7 bytes
- 7 UTF-16 units
- What it breaks
- A trailing space in a file name is invisible, sometimes removed and sometimes kept - two files that look identical.
- What a correct application does
- Trimmed consistently, and the resulting name shown to the user.
Characters forbidden in file names
filenames-paths/illegal-chars
a:b*c?d"e<f>g|h
a:b*c?d"e<f>g|h
- 15 graphemes
- 15 code points
- 15 bytes
- 15 UTF-16 units
- What it breaks
- Characters legal on one system and forbidden on another; a file created on one machine cannot be copied to another.
- What a correct application does
- Rejected with the forbidden characters named, before the file is created.
Double extension
filenames-paths/double-extension
report.txt.exe
report.txt.exe
- 14 graphemes
- 14 code points
- 14 bytes
- 14 UTF-16 units
- What it breaks
- Interfaces hiding known extensions show this as report.txt, so the user sees a document and gets a program.
- What a correct application does
- The full name shown wherever the user makes a decision about the file.
Right-to-left override in a file name
filenames-paths/rtl-extension
reporttxt.exe
report\u202Etxt.exe
- 1 character that changes the direction of text
- 14 graphemes
- 14 code points
- 16 bytes
- 14 UTF-16 units
- What it breaks
- A direction override makes the extension read in reverse, so a program looks like a text file.
- What a correct application does
- Direction-control characters stripped or neutralised in every file name display.
A single dot
filenames-paths/dot-only
.
.
- 1 grapheme
- 1 code point
- 1 byte
- 1 UTF-16 unit
- What it breaks
- A single dot means "this directory"; used as a file name it either fails or does something unintended.
- What a correct application does
- Rejected at input.
Two dots
filenames-paths/dotdot
..
..
- 2 graphemes
- 2 code points
- 2 bytes
- 2 UTF-16 units
- What it breaks
- Two dots mean the parent directory; the shortest possible traversal test.
- What a correct application does
- Rejected at input.
Leading dot
filenames-paths/leading-dot
.gitignore
.gitignore
- 10 graphemes
- 10 code points
- 10 bytes
- 10 UTF-16 units
- What it breaks
- A leading dot hides the file on some systems, so an uploaded file disappears from listings.
- What a correct application does
- Accepted, and listed regardless of the leading dot.
File name outside ASCII
filenames-paths/unicode-filename
ćwiczenieąę.txt
ćwiczenie ąę.txt
- 16 graphemes
- 16 code points
- 19 bytes
- 16 UTF-16 units
- What it breaks
- Non-ASCII names break archives, transfers and any layer assuming a narrow encoding.
- What a correct application does
- Stored, listed, downloaded and archived with the name intact.
260 characters
filenames-paths/path-260
260 × a
- 260 graphemes
- 260 code points
- 260 bytes
- 260 UTF-16 units
- What it breaks
- The classic path length limit; crossing it produces failures far from the place the name was entered.
- What a correct application does
- Rejected with the limit stated, at the point where the name is entered.
Space in a file name
filenames-paths/space-in-name
myreport.txt
my report.txt
- 13 graphemes
- 13 code points
- 13 bytes
- 13 UTF-16 units
- What it breaks
- Names with spaces break command construction and links that are not quoted or encoded.
- What a correct application does
- Handled everywhere the file name is used, including download links.