mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Sanitize credentials in mirror form (#9975)
This commit is contained in:
		@@ -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)"
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user