Skip to content

Commit a768d72

Browse files
authored
Encode values with trailing whitespace (#24)
These would otherwise be treated ambiguously by tools processing the resulting LDIF. This follows RFC 2849 which states: "Values or distinguished names that end with SPACE SHOULD be base-64 encoded." Signed-off-by: Georg Pfuetzenreuter <[email protected]>
1 parent fd88d9b commit a768d72

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func Marshal(l *LDIF) (data string, err error) {
145145
func encodeValue(value string) (string, bool) {
146146
required := false
147147
for _, r := range value {
148-
if r < ' ' || r > '~' { // ~ = 0x7E, <DEL> = 0x7F
148+
if r < ' ' || r > '~' || value[len(value)-1:] == " " { // ~ = 0x7E, <DEL> = 0x7F
149149
required = true
150150
break
151151
}

0 commit comments

Comments
 (0)