1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-26 14:46:24 -07:00

Enable processing of files with extensions explicitly allowed by the admin

This commit is contained in:
Eggbertx 2023-04-26 13:23:12 -07:00
parent ef5a9f49c3
commit 530011be61
4 changed files with 21 additions and 9 deletions

View file

@ -60,7 +60,7 @@ func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter,
gcutil.LogStr("originalFilename", upload.OriginalFilename, errEv, infoEv)
boardConfig := config.GetBoardConfig(postBoard.Dir)
if !boardConfig.AcceptexExtension(upload.OriginalFilename) {
if !boardConfig.AcceptedExtension(upload.OriginalFilename) {
errEv.Caller().Msg("Upload filetype not supported")
server.ServeError(writer, "Upload filetype not supported", wantsJSON, map[string]interface{}{
"filename": upload.OriginalFilename,
@ -190,7 +190,7 @@ func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter,
upload.ThumbnailWidth, upload.ThumbnailHeight = getThumbnailSize(
upload.Width, upload.Height, postBoard.Dir, thumbType)
}
} else if ext == ".pdf" || ext == ".zip" {
} else if ext == ".pdf" || ext == ".zip" || boardConfig.AcceptedOtherExtension(ext) {
stat, err := os.Stat(filePath)
if err != nil {
errEv.Err(err).Caller().
@ -212,8 +212,16 @@ func AttachUploadFromRequest(request *http.Request, writer http.ResponseWriter,
switch ext {
case ".pdf":
staticThumbPath = "static/pdfthumb.png"
case ".txt":
staticThumbPath = "static/txtthumb.png"
case ".gz":
fallthrough
case ".xz":
fallthrough
case ".zip":
staticThumbPath = "static/archivethumb.png"
default:
staticThumbPath = "static/otherthumb.png"
}
originalThumbPath := path.Join(documentRoot, staticThumbPath)
if _, err = os.Stat(originalThumbPath); err != nil {