1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-09-09 09:56:24 -07:00

Fix anti-patterns pointed out by DeepSource

But not the switch fallthroughs/expression lists, there's no benefit
This commit is contained in:
Eggbertx 2020-07-09 15:54:31 -07:00
parent 497a3925e0
commit 55317504a1
17 changed files with 53 additions and 67 deletions

View file

@ -93,9 +93,9 @@ func MakePost(writer http.ResponseWriter, request *http.Request) {
post.Password = gcutil.Md5Sum(password)
// Reverse escapes
nameCookie = strings.Replace(formName, "&", "&", -1)
nameCookie = strings.Replace(nameCookie, "\\'", "'", -1)
nameCookie = strings.Replace(url.QueryEscape(nameCookie), "+", "%20", -1)
nameCookie = strings.ReplaceAll(formName, "&", "&")
nameCookie = strings.ReplaceAll(nameCookie, "\\'", "'")
nameCookie = strings.ReplaceAll(url.QueryEscape(nameCookie), "+", "%20")
// add name and email cookies that will expire in a year (31536000 seconds)
http.SetCookie(writer, &http.Cookie{Name: "name", Value: nameCookie, MaxAge: yearInSeconds})
@ -223,8 +223,8 @@ func MakePost(writer http.ResponseWriter, request *http.Request) {
}
boardDir := _board.Dir
filePath = path.Join(config.Config.DocumentRoot, "/"+boardDir+"/src/", post.Filename)
thumbPath = path.Join(config.Config.DocumentRoot, "/"+boardDir+"/thumb/", strings.Replace(post.Filename, "."+filetype, "t."+thumbFiletype, -1))
catalogThumbPath = path.Join(config.Config.DocumentRoot, "/"+boardDir+"/thumb/", strings.Replace(post.Filename, "."+filetype, "c."+thumbFiletype, -1))
thumbPath = path.Join(config.Config.DocumentRoot, "/"+boardDir+"/thumb/", strings.ReplaceAll(post.Filename, "."+filetype, "t."+thumbFiletype))
catalogThumbPath = path.Join(config.Config.DocumentRoot, "/"+boardDir+"/thumb/", strings.ReplaceAll(post.Filename, "."+filetype, "c."+thumbFiletype))
if err = ioutil.WriteFile(filePath, data, 0777); err != nil {
gclog.Printf(gclog.LErrorLog, "Couldn't write file %q: %s", post.Filename, err.Error())