Skip to content

Commit

Permalink
trim filename ..
Browse files Browse the repository at this point in the history
  • Loading branch information
sjqzhang committed Jan 2, 2025
1 parent 9594d16 commit f0599f0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/http_upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (c *Server) Upload(w http.ResponseWriter, r *http.Request) {
)
if Config().AuthUrl != "" {
if !c.CheckAuth(w, r) {
msg:= "auth fail"
msg := "auth fail"
// log.Warn(msg, r.Form)
c.NotPermit(w, r)
result.Message = msg
Expand Down Expand Up @@ -397,7 +397,7 @@ func (c *Server) upload(w http.ResponseWriter, r *http.Request) {
func (c *Server) TrimFileNameSpecialChar(str string) string {
// trim special char in filename for example: #@%$^&*()_+{}|:"<>?[];',./
reg := regexp.MustCompile(`[\/\\\:\*\?\"\<\>\|\(\)\[\]\{\}\,\;\'\#\@\%\&\$\^\~\=\+\-\!\~\s]`)
return strings.Replace(reg.ReplaceAllString(str, ""), "...", "", -1)
return strings.Replace(strings.Replace(reg.ReplaceAllString(str, ""), "...", "", -1), "..", "", -1)
}

func (c *Server) SaveUploadFile(file multipart.File, header *multipart.FileHeader, fileInfo *FileInfo, r *http.Request) (*FileInfo, error) {
Expand Down

0 comments on commit f0599f0

Please sign in to comment.