From: Pierangelo Masarati Date: Sat, 29 Sep 2001 10:29:24 +0000 (+0000) Subject: liberal treatment of trailing spaces in changetype and mod op lines in ldif files... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1029 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=77dc11ba3ce495b430c9d29796f0842bd5af5c3e;p=openldap liberal treatment of trailing spaces in changetype and mod op lines in ldif files (needs -DLIBERAL_CHANGETYPE_MODOP) --- diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 121bd64821..004bfb4a53 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -805,6 +805,23 @@ process_ldif_rec( char *rbuf, int count ) } if ( strcasecmp( type, T_CHANGETYPESTR ) == 0 ) { +#ifdef LIBERAL_CHANGETYPE_MODOP + /* trim trailing spaces (and log warning ...) */ + + int icnt; + for ( icnt = val.bv_len; --icnt > 0; ) { + if ( !isspace( val.bv_val[icnt] ) ) { + break; + } + } + + if ( ++icnt != val.bv_len ) { + fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n", + prog, T_CHANGETYPESTR, val.bv_val, linenum, dn ); + val.bv_val[icnt] = '\0'; + } +#endif /* LIBERAL_CHANGETYPE_MODOP */ + if ( strcasecmp( val.bv_val, T_MODIFYCTSTR ) == 0 ) { new_entry = 0; expect_modop = 1; @@ -833,6 +850,23 @@ process_ldif_rec( char *rbuf, int count ) } if ( expect_modop ) { +#ifdef LIBERAL_CHANGETYPE_MODOP + /* trim trailing spaces (and log warning ...) */ + + int icnt; + for ( icnt = val.bv_len; --icnt > 0; ) { + if ( !isspace( val.bv_val[icnt] ) ) { + break; + } + } + + if ( ++icnt != val.bv_len ) { + fprintf( stderr, "%s: illegal trailing space after \"%s: %s\" trimmed (line %d of entry \"%s\")\n", + prog, type, val.bv_val, linenum, dn ); + val.bv_val[icnt] = '\0'; + } +#endif /* LIBERAL_CHANGETYPE_MODOP */ + expect_modop = 0; expect_sep = 1; if ( strcasecmp( type, T_MODOPADDSTR ) == 0 ) {