From e644d45c1400aced58747ed86f69239ec7730c21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Anda=20Estensen?= Date: Tue, 17 May 2022 13:56:52 +0200 Subject: [PATCH] all: use strings.EqualFold for string comparison (#24890) --- console/prompt/prompter.go | 2 +- core/asm/compiler.go | 4 ++-- node/rpcstack.go | 2 +- node/rpcstack_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/console/prompt/prompter.go b/console/prompt/prompter.go index 810b6c3e14..2a20b6906a 100644 --- a/console/prompt/prompter.go +++ b/console/prompt/prompter.go @@ -143,7 +143,7 @@ func (p *terminalPrompter) PromptPassword(prompt string) (passwd string, err err // choice to be made, returning that choice. func (p *terminalPrompter) PromptConfirm(prompt string) (bool, error) { input, err := p.Prompt(prompt + " [y/n] ") - if len(input) > 0 && strings.ToUpper(input[:1]) == "Y" { + if len(input) > 0 && strings.EqualFold(input[:1], "y") { return true, nil } return false, err diff --git a/core/asm/compiler.go b/core/asm/compiler.go index 130b0f9b60..ce2d23abd0 100644 --- a/core/asm/compiler.go +++ b/core/asm/compiler.go @@ -243,12 +243,12 @@ func (c *Compiler) pushBin(v interface{}) { // isPush returns whether the string op is either any of // push(N). func isPush(op string) bool { - return strings.ToUpper(op) == "PUSH" + return strings.EqualFold(op, "PUSH") } // isJump returns whether the string op is jump(i) func isJump(op string) bool { - return strings.ToUpper(op) == "JUMPI" || strings.ToUpper(op) == "JUMP" + return strings.EqualFold(op, "JUMPI") || strings.EqualFold(op, "JUMP") } // toBinary converts text to a vm.OpCode diff --git a/node/rpcstack.go b/node/rpcstack.go index 2ee47d250a..0d2be9008a 100644 --- a/node/rpcstack.go +++ b/node/rpcstack.go @@ -357,7 +357,7 @@ func (h *httpServer) wsAllowed() bool { // isWebsocket checks the header of an http request for a websocket upgrade request. func isWebsocket(r *http.Request) bool { - return strings.ToLower(r.Header.Get("Upgrade")) == "websocket" && + return strings.EqualFold(r.Header.Get("Upgrade"), "websocket") && strings.Contains(strings.ToLower(r.Header.Get("Connection")), "upgrade") } diff --git a/node/rpcstack_test.go b/node/rpcstack_test.go index 60fcab5a90..c7dba8a1ef 100644 --- a/node/rpcstack_test.go +++ b/node/rpcstack_test.go @@ -283,7 +283,7 @@ func rpcRequest(t *testing.T, url string, extraHeaders ...string) *http.Response } for i := 0; i < len(extraHeaders); i += 2 { key, value := extraHeaders[i], extraHeaders[i+1] - if strings.ToLower(key) == "host" { + if strings.EqualFold(key, "host") { req.Host = value } else { req.Header.Set(key, value)