Strip Userinfo from log entries and errors #2051

This commit is contained in:
Alex X
2026-01-21 17:14:14 +03:00
parent 6eeba1ae4c
commit de157eb144
3 changed files with 32 additions and 33 deletions
-12
View File
@@ -2,7 +2,6 @@ package core
import (
"crypto/rand"
"regexp"
"runtime"
"strconv"
"strings"
@@ -93,14 +92,3 @@ func Caller() string {
_, file, line, _ := runtime.Caller(1)
return file + ":" + strconv.Itoa(line)
}
const (
unreserved = `A-Za-z0-9-._~`
subdelims = `!$&'()*+,;=`
userinfo = unreserved + subdelims + `%:`
)
func StripUserinfo(s string) string {
sanitizer := regexp.MustCompile(`://[` + userinfo + `]+@`)
return sanitizer.ReplaceAllString(s, `://***@`)
}