shelldap
changeset 5 78b2a48e07db
parent 4 5a65bc849363
child 6 46dfe9d6f368
--- a/shelldap	Thu Jul 15 09:01:05 2010 -0700
+++ b/shelldap	Thu Feb 17 12:35:21 2011 -0800
@@ -867,6 +867,21 @@
 	}
 }
 
+sub unwrap {
+	my $array = shift;
+
+	my $iter = 1;
+	while ($iter < $#$array) {
+		if (@$array[$iter] =~ m/^\W/) {
+			@$array[$iter - 1] =~ s/\n$//;
+			@$array[$iter] =~ s/^\W//;
+			splice(@$array, $iter - 1, 2, @$array[$iter - 1] . @$array[$iter]);
+		} else {
+			$iter++;
+		}
+	}
+}
+
 ###############################################################
 #
 # SHELL METHODS
@@ -1233,13 +1248,15 @@
 
 	my $parse = sub {
 		my $line = shift || $_;
-		return unless $line =~ /^\w/; # ignore multiline
 		return if $line	 =~ /^\#/; # ignore comments
 		my ( $attr, $val ) = ( $1, $2 ) if $line =~ /^(.+?): (.*)$/;
 		return if index($attr, ':') != -1;  # ignore base64
 		return ( $attr, $val );
 	};
 
+	unwrap(\@orig_ldif);
+	unwrap(\@new_ldif);
+
 	my $diff = Algorithm::Diff->new( \@orig_ldif, \@new_ldif );
 	HUNK:
 	while ( $diff->Next() ) {
@@ -1250,7 +1267,6 @@
 		# total deletions
 		if ( $diff_bit == 1 ) {
 			foreach ( $diff->Items(1) ) {
-				next unless /\w+/;
 				$self->debug("DELETE: $_");
 				my ( $attr, $val ) = $parse->( $_ ) or next;
 				$e->delete( $attr => [ $val ] );
@@ -1260,7 +1276,6 @@
 		# new insertions
 		if ( $diff_bit == 2 ) {
 			foreach ( $diff->Items(2) ) {
-				next unless /\w+/;
 				$self->debug("INSERT: $_");
 				my ( $attr, $val ) = $parse->( $_ ) or next;
 				$e->add( $attr => $val );
@@ -1268,10 +1283,8 @@
 		}
 
 		# replacements
-		# these are trickier with multivalue lines
 		if ( $diff_bit == 3 ) {
 			foreach ( $diff->Items(2) ) {
-				next unless /\w+/;
 				$self->debug("MODIFY: $_");
 				my ( $attr, $val ) = $parse->( $_ ) or next;