1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 02:08:36 +00:00

Sanitize credentials in mirror form (#9975)

This commit is contained in:
Lunny Xiao
2020-01-25 18:57:43 +08:00
committed by zeripath
parent 5b17bb8f3d
commit a67c06ce90
4 changed files with 37 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ package util
import (
"net/url"
"strings"
"code.gitea.io/gitea/modules/log"
)
// urlSafeError wraps an error whose message may contain a sensitive URL
@@ -36,6 +38,7 @@ func SanitizeMessage(message, unsanitizedURL string) string {
func SanitizeURLCredentials(unsanitizedURL string, usePlaceholder bool) string {
u, err := url.Parse(unsanitizedURL)
if err != nil {
log.Error("parse url %s failed: %v", unsanitizedURL, err)
// don't log the error, since it might contain unsanitized URL.
return "(unparsable url)"
}