]> git.sur5r.net Git - openldap/commitdiff
Add better space compression
authorKurt Zeilenga <kurt@openldap.org>
Sat, 21 Oct 2000 03:27:41 +0000 (03:27 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 21 Oct 2000 03:27:41 +0000 (03:27 +0000)
servers/slapd/dn.c

index 41ecb7bb003b6dab53ed401994691c1479649db5..8ae52ec09569cea7da6ebc03f061910b7e2b4f5a 100644 (file)
  */
 
 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 ) {