mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-21 00:20:50 +00:00
Sanitize credentials in mirror form (#9975)
This commit is contained in:
parent
5b17bb8f3d
commit
a67c06ce90
4 changed files with 37 additions and 1 deletions
|
@ -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)"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue