Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Fixed book download filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
pgaskin committed Aug 14, 2018
1 parent 5af5c74 commit 6f6bf15
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/url"
"os"
"path/filepath"
"regexp"
"runtime/debug"
"strings"
"time"
Expand Down Expand Up @@ -237,7 +238,7 @@ func (s *Server) handleDownload(w http.ResponseWriter, r *http.Request, p httpro
return
}

w.Header().Set("Content-Disposition", "attachment; filename="+url.PathEscape(b.Title)+"."+b.FileType())
w.Header().Set("Content-Disposition", `attachment; filename="`+regexp.MustCompile("[[:^ascii:]]").ReplaceAllString(b.Title, "_")+`.`+b.FileType()+`"`)
switch b.FileType() {
case "epub":
w.Header().Set("Content-Type", "application/epub+zip")
Expand Down

0 comments on commit 6f6bf15

Please sign in to comment.