summaryrefslogtreecommitdiff
path: root/upload-svr.go
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2019-09-10 00:06:20 +0100
committerPeter Wu <peter@lekensteyn.nl>2019-09-10 00:06:20 +0100
commit91616baae2b271eeb551ceec0333c92d6294cf79 (patch)
treea85ff7ce49f09f0bede4057852acd315097b77f4 /upload-svr.go
parenteb3fd69245d012465a90af477bcb8c57d9826081 (diff)
downloadscripts-91616baae2b271eeb551ceec0333c92d6294cf79.tar.gz
upload-svr.go: fix panic with long filenames
Diffstat (limited to 'upload-svr.go')
-rw-r--r--upload-svr.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/upload-svr.go b/upload-svr.go
index efba0c9..2564f6b 100644
--- a/upload-svr.go
+++ b/upload-svr.go
@@ -93,14 +93,16 @@ func showIndex(w http.ResponseWriter, r *http.Request, msg string) {
relpath += "/"
}
disppath := relpath
+ pad := ""
if len(relpath) > maxFilenameLength {
tail := "..>"
if info.IsDir() {
tail += "/"
}
disppath = disppath[:maxFilenameLength-len(tail)] + tail
+ } else {
+ pad = strings.Repeat(" ", maxFilenameLength-len(relpath))
}
- pad := strings.Repeat(" ", maxFilenameLength-len(relpath))
sz := "-"
if !info.IsDir() {
sz = strconv.FormatInt(info.Size(), 10)