add a check to prevent panics (#5471)
This commit is contained in:
parent
380796f4fe
commit
3e3c195773
|
@ -377,6 +377,10 @@ func (c *Client) GetLdapGroups(cfg *ConfigEntry, conn Connection, userDN string,
|
||||||
|
|
||||||
// EscapeLDAPValue is exported because a plugin uses it outside this package.
|
// EscapeLDAPValue is exported because a plugin uses it outside this package.
|
||||||
func EscapeLDAPValue(input string) string {
|
func EscapeLDAPValue(input string) string {
|
||||||
|
if input == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// RFC4514 forbids un-escaped:
|
// RFC4514 forbids un-escaped:
|
||||||
// - leading space or hash
|
// - leading space or hash
|
||||||
// - trailing space
|
// - trailing space
|
||||||
|
|
|
@ -11,6 +11,7 @@ func TestLDAPEscape(t *testing.T) {
|
||||||
"test,hel+lo": "test\\,hel\\+lo",
|
"test,hel+lo": "test\\,hel\\+lo",
|
||||||
"test\\hello": "test\\\\hello",
|
"test\\hello": "test\\\\hello",
|
||||||
" test ": "\\ test \\ ",
|
" test ": "\\ test \\ ",
|
||||||
|
"": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
for test, answer := range testcases {
|
for test, answer := range testcases {
|
||||||
|
|
Loading…
Reference in a new issue