EscapeLDAPValue - catch trailing escape character (#13452)
* [VAULT-4018] - EscapeLDAPValue catch trailing escape character
This commit is contained in:
parent
0bd6f5392c
commit
62ecf23c2c
|
@ -0,0 +1,3 @@
|
|||
```release-note:bug
|
||||
sdk/helper/ldaputil: properly escape a trailing escape character to prevent panics.
|
||||
```
|
|
@ -512,7 +512,7 @@ func EscapeLDAPValue(input string) string {
|
|||
// - null
|
||||
for i := 0; i < len(input); i++ {
|
||||
escaped := false
|
||||
if input[i] == '\\' {
|
||||
if input[i] == '\\' && i+1 < len(input)-1 {
|
||||
i++
|
||||
escaped = true
|
||||
}
|
||||
|
|
|
@ -32,6 +32,9 @@ func TestLDAPEscape(t *testing.T) {
|
|||
"test\\hello": "test\\\\hello",
|
||||
" test ": "\\ test \\ ",
|
||||
"": "",
|
||||
"\\test": "\\\\test",
|
||||
"test\\": "test\\\\",
|
||||
"test\\ ": "test\\\\\\ ",
|
||||
}
|
||||
|
||||
for test, answer := range testcases {
|
||||
|
|
Loading…
Reference in New Issue