Chore: Use strings.ReplaceAll and preallocate containers (#58483)
This commit is contained in:
@@ -14,7 +14,7 @@ func hello(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
safeBody := strings.Replace(string(body), "\n", "", -1)
|
||||
safeBody := strings.ReplaceAll(string(body), "\n", "")
|
||||
line := fmt.Sprintf("webbhook: -> %s", safeBody)
|
||||
fmt.Println(line)
|
||||
if _, err := io.WriteString(w, line); err != nil {
|
||||
|
||||
@@ -32,8 +32,8 @@ func main() {
|
||||
proxy := httputil.NewSingleHostReverseProxy(originURL)
|
||||
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
safeSleep := strings.Replace(sleep.String(), "\n", "", -1)
|
||||
safeRequestUri := strings.Replace(r.RequestURI, "\n", "", -1)
|
||||
safeSleep := strings.ReplaceAll(sleep.String(), "\n", "")
|
||||
safeRequestUri := strings.ReplaceAll(r.RequestURI, "\n", "")
|
||||
log.Printf("sleeping for %s then proxying request: url '%s'", safeSleep, safeRequestUri)
|
||||
|
||||
// This is commented out as CodeQL flags this as vulnerability CWE-117 (https://cwe.mitre.org/data/definitions/117.html)
|
||||
|
||||
Reference in New Issue
Block a user