mirror of https://github.com/gogs/gogs.git
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.pull/5181/head
parent
cb47595f13
commit
c0b45fa36f
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue