mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 17:24:22 +00:00 
			
		
		
		
	Fix open redirect vulnerability on login screen (#4312)
* Fix open redirect vulnerability on login screen Signed-off-by: Jonas Franz <info@jonasfranz.software> * Reorder imports Signed-off-by: Jonas Franz <info@jonasfranz.software> * Replace www. from Domain too Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
		@@ -10,6 +10,7 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// OptionalBool a boolean that can be "null"
 | 
			
		||||
@@ -78,6 +79,18 @@ func URLJoin(base string, elems ...string) string {
 | 
			
		||||
	return joinedURL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// IsExternalURL checks if rawURL points to an external URL like http://example.com
 | 
			
		||||
func IsExternalURL(rawURL string) bool {
 | 
			
		||||
	parsed, err := url.Parse(rawURL)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	if len(parsed.Host) != 0 && strings.Replace(parsed.Host, "www.", "", 1) != strings.Replace(setting.Domain, "www.", "", 1) {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Min min of two ints
 | 
			
		||||
func Min(a, b int) int {
 | 
			
		||||
	if a > b {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user