*/
char *
-dn_validate( char *dn )
+dn_validate( char *dn_in )
{
char *d, *s;
int state, gotesc;
+ char *dn = dn_in;
gotesc = 0;
state = B4LEADTYPE;
!RDN_SEPARATOR( *s ) ) {
*--d = *s;
d++;
- } else {
+ } else if( !ASCII_SPACE( *s ) || !ASCII_SPACE( *(d - 1) ) ) {
*d++ = *s;
}
break;
} else if ( gotesc && !RDN_NEEDSESCAPE( *s ) ) {
*--d = *s;
d++;
- } else {
+ } else if( !ASCII_SPACE( *s ) || !ASCII_SPACE( *(d - 1) ) ) {
*d++ = *s;
}
break;
if ( RDN_SEPARATOR( *s ) ) {
state = B4TYPE;
*d++ = *s;
+ } else if ( !ASCII_SPACE( *s ) ) {
+ dn = NULL;
}
break;
gotesc = 0;
}
}
+
+ /* trim trailing spaces */
+ while( d > dn_in && ASCII_SPACE( *(d-1) ) ) {
+ --d;
+ }
*d = '\0';
if( gotesc ) {