mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-18 11:46:23 -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:
parent
497a3925e0
commit
55317504a1
17 changed files with 53 additions and 67 deletions
|
@ -108,7 +108,7 @@ func ServeCaptcha(writer http.ResponseWriter, request *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
func getCaptchaImage() (captchaID string, chaptchaB64 string) {
|
||||
func getCaptchaImage() (captchaID, chaptchaB64 string) {
|
||||
if !config.Config.UseCaptcha {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -79,7 +79,7 @@ func getNewFilename() string {
|
|||
}
|
||||
|
||||
// find out what out thumbnail's width and height should be, partially ripped from Kusaba X
|
||||
func getThumbnailSize(w int, h int, size string) (newWidth int, newHeight int) {
|
||||
func getThumbnailSize(w, h int, size string) (newWidth, newHeight int) {
|
||||
var thumbWidth int
|
||||
var thumbHeight int
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue