Skip to content

Commit 63e6dbd

Browse files
committed
Avoid strings.ReplaceAll() that was introduced too recently
1 parent ed0dbc2 commit 63e6dbd

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

dnscrypt-proxy/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,15 @@ func StringQuote(str string) string {
134134
return str[1 : len(str)-1]
135135
}
136136

137+
func StringStripSpaces(str string) string {
138+
return strings.Map(func(r rune) rune {
139+
if unicode.IsSpace(r) {
140+
return -1
141+
}
142+
return r
143+
}, str)
144+
}
145+
137146
func ExtractPort(str string, defaultPort int) int {
138147
port := defaultPort
139148
if idx := strings.LastIndex(str, ":"); idx >= 0 && idx < len(str)-1 {

dnscrypt-proxy/plugins.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func InitPluginsGlobals(pluginsGlobals *PluginsGlobals, proxy *Proxy) error {
154154

155155
// blockedQueryResponse can be 'refused', 'hinfo' or IP responses 'a:IPv4,aaaa:IPv6
156156
func parseBlockedQueryResponse(blockedResponse string, pluginsGlobals *PluginsGlobals) {
157-
blockedResponse = strings.ReplaceAll(strings.ToLower(blockedResponse), " ", "")
157+
blockedResponse = StringStripSpaces(strings.ToLower(blockedResponse))
158158

159159
if strings.HasPrefix(blockedResponse, "a:") {
160160
blockedIPStrings := strings.Split(blockedResponse, ",")

0 commit comments

Comments
 (0)