Artifact ed213d9a2d70a4e780ff841a24856131611b5b2674e44b747748eab92c602f41:
- File
internal/manifest/writer_name_test.go
— part of check-in
[357d10dac6]
at
2026-10-11 23:39:02
on branch main
— fix(manifest): refuse check-in filenames outside the writer profile (#270) (#321)
Checkin wrote any F-card filename it was given. The artifact format's writer profile (4.6.1) forbids a backslash and anything but valid UTF-8, surrogates and overlong forms included; fossil rejects a manifest that names one. storeFileBlobs now refuses such a name or old name before storing anything. (user: [email protected], size: 679) [annotate] [blame] [check-ins using]
package manifest import "testing" // A writer may not create a filename that a parser would nonetheless accept // (section 4.6.1 of the artifact format). func TestCheckWriterName(t *testing.T) { tests := []struct { name string wantErr bool }{ {"", false}, // OldName's "no rename" {"dir/a b.txt", false}, {"é/ü.txt", false}, {"a\\b.txt", true}, {"a\xff.txt", true}, {"a\xed\xa0\x80.txt", true}, // UTF-16 surrogate U+D800 {"a\xc0\x80.txt", true}, // overlong NUL } for _, tt := range tests { if err := checkWriterName(tt.name); (err != nil) != tt.wantErr { t.Errorf("checkWriterName(%q) = %v, wantErr %v", tt.name, err, tt.wantErr) } } }