hostilenames

package
v0.60.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package hostilenames is the one list of hostile file names every surface of filex is tested with: Turkish and CJK letters, right-to-left scripts, emoji, the same name composed and decomposed, spaces and dots at the ends, URL and shell metacharacters, Windows device names and forbidden characters, names at and over the 255-byte limit, invisible and bidi control characters, case twins (task #238).

The list is names.json beside this file. The e2e specs, the web unit tests and the desktop scripts read the same file through ONE small JavaScript reader (e2e/helpers/hostile-names.mjs), so a name added there reaches every surface. ⚠ Never copy a name into a second list: add it to names.json.

Like archivetest it imports nothing from filex, so any package's internal tests can use it without an import cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Name

type Name struct {
	// ID is stable and safe in a test name or a log line ("rlo-extension").
	ID string
	// Name is the name itself, invisible characters and all.
	Name string
	// Why says in a few words what the name breaks.
	Why string
	// Tags group the names: unicode, cjk, rtl, emoji, nfd, space, dots, url,
	// html, quote, separator, win-reserved, win-forbidden, long,
	// over-255-bytes, invisible, bidi-control, control, case.
	Tags []string
	// Refused: no filex surface may create a file with this name.
	Refused bool
	// WindowsInvalid: the name cannot exist as a file name on Windows (a
	// device name, a forbidden character, a trailing space or dot).
	WindowsInvalid bool
	// Twin is the ID of the name that is the same name to a case- or
	// normalisation-insensitive file system, TwinKind why.
	Twin     string
	TwinKind TwinKind
}

Name is one hostile name.

func All

func All() []Name

All is every hostile name, in the file's order. The slice is the caller's.

func Creatable

func Creatable() []Name

Creatable is every name a filex surface must accept (not Refused).

func Filter

func Filter(keep func(Name) bool) []Name

Filter is every name keep accepts, in the file's order.

func ForLocalDisk

func ForLocalDisk() []Name

ForLocalDisk is every Creatable name the test machine's own file system can hold side by side in ONE folder - what a test writes through a local-disk storage, which keeps the name it is given:

  • no name over 255 bytes, except on Windows, whose limit is 255 UTF-16 units (TooLongForLocalDisk has them, for the refusal);
  • on Windows, no name Windows refuses (WindowsInvalid);
  • on Windows and macOS, whose file systems are case-insensitive (and on macOS normalisation-insensitive), only the first name of each twin pair: the second would land on the first.

The suite runs on Linux, where every name but those over 255 bytes is kept; the filter is what lets the same test pass on a developer's laptop.

func Get

func Get(id string) Name

Get is the name with id; it panics on an unknown id (a typo in a test).

func Refused

func Refused() []Name

Refused is every name no filex surface may create.

func TooLongForLocalDisk

func TooLongForLocalDisk() []Name

TooLongForLocalDisk is every Creatable name the test machine's file system refuses for its length: over 255 bytes on Linux and macOS (ENAMETOOLONG). Empty on Windows, which counts UTF-16 units and holds them all.

func Without

func Without(names []Name, tags ...string) []Name

Without is every name carrying none of tags — the names a surface can carry at all (an FTP command line cannot carry a line break; a URL path cannot carry a NUL).

func (Name) Bytes

func (n Name) Bytes() int

Bytes is the length of the name in bytes of UTF-8.

func (Name) Has

func (n Name) Has(tag string) bool

Has reports whether the name carries tag.

type Path

type Path struct {
	ID   string
	Path string
	Why  string
	// Depth is how many folders the path goes through before its leaf.
	Depth int
	// Leaf is the file name at the end of the path.
	Leaf string
}

Path is a hostile relative path (slash-separated, no leading slash).

func Deep

func Deep() Path

Deep is the deep path (64 folders, about 900 bytes).

func Paths

func Paths() []Path

Paths is every hostile path.

func (Path) Dirs

func (p Path) Dirs() []string

Dirs is every folder of the path, shortest first ("a", "a/b", ...): the order a test creates them in.

type TwinKind

type TwinKind string

TwinKind says why two names are one name to some file system.

const (
	// TwinCase: the names differ only in letter case (Windows, macOS).
	TwinCase TwinKind = "case"
	// TwinNFC: the same text composed and decomposed (macOS).
	TwinNFC TwinKind = "nfc-nfd"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL