mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	EscapeLDAPValue - catch trailing escape character (#13452)
* [VAULT-4018] - EscapeLDAPValue catch trailing escape character
This commit is contained in:
		
							
								
								
									
										3
									
								
								changelog/13452.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								changelog/13452.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -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 | 	// - null | ||||||
| 	for i := 0; i < len(input); i++ { | 	for i := 0; i < len(input); i++ { | ||||||
| 		escaped := false | 		escaped := false | ||||||
| 		if input[i] == '\\' { | 		if input[i] == '\\' && i+1 < len(input)-1 { | ||||||
| 			i++ | 			i++ | ||||||
| 			escaped = true | 			escaped = true | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -32,6 +32,9 @@ func TestLDAPEscape(t *testing.T) { | |||||||
| 		"test\\hello": "test\\\\hello", | 		"test\\hello": "test\\\\hello", | ||||||
| 		"  test  ":    "\\  test \\ ", | 		"  test  ":    "\\  test \\ ", | ||||||
| 		"":            "", | 		"":            "", | ||||||
|  | 		"\\test":      "\\\\test", | ||||||
|  | 		"test\\":      "test\\\\", | ||||||
|  | 		"test\\ ":     "test\\\\\\ ", | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	for test, answer := range testcases { | 	for test, answer := range testcases { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Vinny Mannello
					Vinny Mannello