Compare commits
1
Commits
91757752b8
..
v0.4.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
522e016a29 |
@@ -26,10 +26,7 @@ type Attachment struct {
|
|||||||
SizeHuman string `json:"-"` // template-only: human-readable size
|
SizeHuman string `json:"-"` // template-only: human-readable size
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxFilenameLen caps stored attachment filenames (bytes) to bound DB
|
const MaxFilenameLen = 255
|
||||||
// rows and Content-Disposition echoes. 128 keeps names readable while
|
|
||||||
// stopping filename-bloat abuse; longer names truncate.
|
|
||||||
const MaxFilenameLen = 128
|
|
||||||
|
|
||||||
// ErrFileTooLarge is returned when an attachment exceeds the per-file cap.
|
// ErrFileTooLarge is returned when an attachment exceeds the per-file cap.
|
||||||
var ErrFileTooLarge = errors.New("file too large")
|
var ErrFileTooLarge = errors.New("file too large")
|
||||||
|
|||||||
@@ -105,9 +105,4 @@ func TestSanitizeFilename(t *testing.T) {
|
|||||||
if got := SanitizeFilename(long); len(got) != MaxFilenameLen {
|
if got := SanitizeFilename(long); len(got) != MaxFilenameLen {
|
||||||
t.Errorf("long name len = %d want %d", len(got), MaxFilenameLen)
|
t.Errorf("long name len = %d want %d", len(got), MaxFilenameLen)
|
||||||
}
|
}
|
||||||
// issue #248: a 250-char multipart filename must truncate to the cap
|
|
||||||
repro := strings.Repeat("b", 246) + ".txt"
|
|
||||||
if got := SanitizeFilename(repro); len(got) != MaxFilenameLen {
|
|
||||||
t.Errorf("repro name len = %d want %d", len(got), MaxFilenameLen)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user