Compare commits
4
Commits
v0.4.0
..
ca785f5648
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca785f5648 | ||
|
|
91757752b8 | ||
|
|
bb2c5e200c | ||
|
|
8474b8eb02 |
@@ -26,7 +26,10 @@ type Attachment struct {
|
||||
SizeHuman string `json:"-"` // template-only: human-readable size
|
||||
}
|
||||
|
||||
const MaxFilenameLen = 255
|
||||
// MaxFilenameLen caps stored attachment filenames (bytes) to bound DB
|
||||
// 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.
|
||||
var ErrFileTooLarge = errors.New("file too large")
|
||||
|
||||
@@ -105,4 +105,9 @@ func TestSanitizeFilename(t *testing.T) {
|
||||
if got := SanitizeFilename(long); 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
{{if not .AttachmentImage}}
|
||||
{{if not .Attachment}}
|
||||
<div class="float">
|
||||
<div class="code" id="code"><div class="gutter" id="gutter">{{.Gutter}}</div><div class="codebody" id="codebody">{{.ContentHTML}}</div></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user