From 38cf4a1d82a94cb47a7881ffc0eebea813052590 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sat, 21 Oct 2000 03:27:41 +0000 Subject: [PATCH] Add better space compression --- servers/slapd/dn.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 41ecb7bb00..8ae52ec095 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -34,10 +34,11 @@ */ char * -dn_validate( char *dn ) +dn_validate( char *dn_in ) { char *d, *s; int state, gotesc; + char *dn = dn_in; gotesc = 0; state = B4LEADTYPE; @@ -121,7 +122,7 @@ dn_validate( char *dn ) !RDN_SEPARATOR( *s ) ) { *--d = *s; d++; - } else { + } else if( !ASCII_SPACE( *s ) || !ASCII_SPACE( *(d - 1) ) ) { *d++ = *s; } break; @@ -133,7 +134,7 @@ dn_validate( char *dn ) } else if ( gotesc && !RDN_NEEDSESCAPE( *s ) ) { *--d = *s; d++; - } else { + } else if( !ASCII_SPACE( *s ) || !ASCII_SPACE( *(d - 1) ) ) { *d++ = *s; } break; @@ -142,6 +143,8 @@ dn_validate( char *dn ) if ( RDN_SEPARATOR( *s ) ) { state = B4TYPE; *d++ = *s; + } else if ( !ASCII_SPACE( *s ) ) { + dn = NULL; } break; @@ -158,6 +161,11 @@ dn_validate( char *dn ) gotesc = 0; } } + + /* trim trailing spaces */ + while( d > dn_in && ASCII_SPACE( *(d-1) ) ) { + --d; + } *d = '\0'; if( gotesc ) { -- 2.39.5