1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-19 00:38:36 +00:00

Sanitize credentials in mirror form (#9975) (#9991)

This commit is contained in:
Lunny Xiao
2020-01-26 16:16:53 +08:00
committed by zeripath
parent 16f7b43903
commit 16dfd9ffbe
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)"
}