mirror of
https://github.com/gogs/gogs.git
synced 2026-02-16 11:26:58 +01:00
ldap: return valid LDAP string if user input lacks "%s" (#5171)
If the user provides a string that does not contain "%s", fmt.Sprintf silently appends "%!(EXTRA type=value)" instead of failing loudly. This fixes #4375.
This commit is contained in:
@@ -56,7 +56,7 @@ func (ls *Source) sanitizedUserQuery(username string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
return fmt.Sprintf(ls.Filter, username), true
|
||||
return strings.Replace(ls.Filter, "%s", username, -1), true
|
||||
}
|
||||
|
||||
func (ls *Source) sanitizedUserDN(username string) (string, bool) {
|
||||
@@ -67,7 +67,7 @@ func (ls *Source) sanitizedUserDN(username string) (string, bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
return fmt.Sprintf(ls.UserDN, username), true
|
||||
return strings.Replace(ls.UserDN, "%s", username, -1), true
|
||||
}
|
||||
|
||||
func (ls *Source) sanitizedGroupFilter(group string) (string, bool) {
|
||||
|
||||
Reference in New Issue
Block a user