File names and paths test values
Names that a file system, an archive or a server rejects, alters, or reads differently than the user meant. 28 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.
Name starting with a dash
filenames-paths/leading-dash
-rf
-rf
- 3 graphemes
- 3 code points
- 3 bytes
- 3 UTF-16 units
- What it breaks
- A name that starts with a dash is read as an option when a script passes it to a command without -- in front of it.
- What a correct application does
- Stored as a name, and every command that receives it gets -- before it.
Percent, plus and hash
filenames-paths/url-specials
100%a+b#1.txt
100% a+b #1.txt
- 15 graphemes
- 15 code points
- 15 bytes
- 15 UTF-16 units
- What it breaks
- A percent sign, a plus and a hash each mean something else in a URL, so a download link built without encoding points at another file or stops at the hash.
- What a correct application does
- Download links encode the name, and the file downloads under the name it was given.
Name starting with two dots
filenames-paths/leading-double-dot
..report.txt
..report.txt
- 12 graphemes
- 12 code points
- 12 bytes
- 12 UTF-16 units
- What it breaks
- A traversal filter that looks for two dots refuses a name that climbs nowhere, and a filter that strips dots stores another name.
- What a correct application does
- Accepted unchanged, or rejected with a message; never stored under a different name.
Only an extension
filenames-paths/extension-only
.txt
.txt
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- With nothing before the dot, code that splits off the extension is left with an empty name, and Linux and macOS hide the file.
- What a correct application does
- Rejected with a message, or accepted and listed with its full name.
Several dots
filenames-paths/many-dots
v1.2.3.final.pdf
v1.2.3.final.pdf
- 16 graphemes
- 16 code points
- 16 bytes
- 16 UTF-16 units
- What it breaks
- Only the part after the last dot is the extension; code that splits at the first dot reads the type as 2.3.final.pdf.
- What a correct application does
- Accepted, with the type taken from the last extension.
No extension
filenames-paths/no-extension
README
README
- 6 graphemes
- 6 code points
- 6 bytes
- 6 UTF-16 units
- What it breaks
- A system that requires an extension, or guesses the type from it, has nothing to go on and may refuse a common file.
- What a correct application does
- Accepted, or rejected with a message that names the missing extension.
Extension in capitals
filenames-paths/upper-extension
REPORT.PDF
REPORT.PDF
- 10 graphemes
- 10 code points
- 10 bytes
- 10 UTF-16 units
- What it breaks
- An extension check that compares with case refuses a file it accepts as report.pdf.
- What a correct application does
- Accepted, like the same name in lower case.
Office lock file name
filenames-paths/office-lock-name
~$report.docx
~$report.docx
- 13 graphemes
- 13 code points
- 13 bytes
- 13 UTF-16 units
- What it breaks
- Microsoft Office names its lock files this way, so sync tools, backups and upload filters may skip the file without saying so.
- What a correct application does
- Stored and listed like any other name, or rejected with a message.
Apache configuration file name
filenames-paths/htaccess
.htaccess
.htaccess
- 9 graphemes
- 9 code points
- 9 bytes
- 9 UTF-16 units
- What it breaks
- On an Apache server that serves the upload folder, a file with this name changes how the server behaves, whatever it holds.
- What a correct application does
- Rejected or renamed before it is stored in a folder the server serves.
IIS configuration file name
filenames-paths/web-config
web.config
web.config
- 10 graphemes
- 10 code points
- 10 bytes
- 10 UTF-16 units
- What it breaks
- On an IIS server that serves the upload folder, a file with this name changes how the server behaves, whatever it holds.
- What a correct application does
- Rejected or renamed before it is stored in a folder the server serves.
Environment file name
filenames-paths/dotenv
.env
.env
- 4 graphemes
- 4 code points
- 4 bytes
- 4 UTF-16 units
- What it breaks
- Applications read their settings and secrets from a file with this name, so an upload that lands in the wrong folder becomes configuration.
- What a correct application does
- Rejected or renamed, and never stored where an application reads its settings.
Windows folder settings file name
filenames-paths/desktop-ini
desktop.ini
desktop.ini
- 11 graphemes
- 11 code points
- 11 bytes
- 11 UTF-16 units
- What it breaks
- Windows Explorer reads a file with this name to decide how a folder looks, so an upload to a shared folder changes it for everyone.
- What a correct application does
- Rejected or renamed in folders that people open in Explorer.
Accent as a separate character
filenames-paths/nfd-name
café.txt
café.txt
- 8 graphemes
- 9 code points
- 10 bytes
- 9 UTF-16 units
- What it breaks
- The accent follows the e as its own character, as macOS hands names over; a system that compares bytes sees a different file from the usual spelling.
- What a correct application does
- Found, matched and listed as the same name as its composed spelling.
Extension in full-width letters
filenames-paths/fullwidth-extension
report.txt
report.txt
- 10 graphemes
- 10 code points
- 16 bytes
- 10 UTF-16 units
- What it breaks
- The extension looks like txt and is not; a type check before normalisation sees one extension and storage after it another.
- What a correct application does
- Rejected, or the name normalised before the type is checked.
Percent-encoded NUL and line break
filenames-paths/encoded-control-name
report%00%0D%0A.txt
report%00%0D%0A.txt
- 19 graphemes
- 19 code points
- 19 bytes
- 19 UTF-16 units
- What it breaks
- Decoded once too often, %00 cuts the name short and %0D%0A starts a header or a log line that nobody wrote.
- What a correct application does
- Stored as typed, and decoded at most once on the way in.
101 bytes, one past the tar name field
filenames-paths/tar-name-101
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu.txt
101 code points in all, cut in the middle
uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu.txt
- 101 graphemes
- 101 code points
- 101 bytes
- 101 UTF-16 units
- What it breaks
- The name field of a ustar tar archive holds 100 bytes, so packing the file into tar cuts the name or moves it to an extra header.
- What a correct application does
- Archived and restored with the whole name.