Index: shelldap
===================================================================
--- shelldap	(revision 5)
+++ shelldap	(revision 6)
@@ -2,5 +2,5 @@
 # vim: set nosta noet ts=4 sw=4:
 #
-# Copyright (c) 2006, Mahlon E. Smith <mahlon@martini.nu>
+# Copyright (c) 2006-2011, Mahlon E. Smith <mahlon@martini.nu>
 # All rights reserved.
 # Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,9 @@
 #     * Redistributions of source code must retain the above copyright
 #       notice, this list of conditions and the following disclaimer.
+#
 #     * Redistributions in binary form must reproduce the above copyright
 #       notice, this list of conditions and the following disclaimer in the
 #       documentation and/or other materials provided with the distribution.
+#
 #     * Neither the name of Mahlon E. Smith nor the names of his
 #       contributors may be used to endorse or promote products derived
@@ -346,11 +348,6 @@
 =head1 BUGS / LIMITATIONS
 
-There is currently no attribute multiline support - attribute values
-that span over one line will be ignored if modified.  (Thankfully, they
-are generally rare.)
-
-There is no support for editing binary data.  This is actually related
-to the lack of multiline support - if you just base64 encode data and
-paste it in, it will be ignored for the same reasons.
+There is no support for editing binary data.  If you need to edit base64
+stuff, just feed it to the regular ldapmodify/ldapadd/etc tools.
 
 =head1 AUTHOR
@@ -868,18 +865,24 @@
 }
 
+
+# Given an $arrayref, remove LDIF continuation wrapping,
+# effectively making each entry a single line.
+# 
 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++;
-		}
-	}
-}
+	my $i = 1;
+	while ( $i < scalar(@$array) ) {
+		if ( $array->[$i] =~ /^\s/ ) {
+			$array->[ $i - 1 ] =~ s/\n$//;
+			$array->[ $i ] =~ s/^\s//;
+			splice( @$array, $i - 1, 2, $array->[$i - 1] . $array->[$i] );
+		}
+		else {
+			$i++;
+		}
+	}
+}
+
 
 ###############################################################
@@ -1159,9 +1162,9 @@
 		return;
 	}
-        my $filter;
-        unless ( $DNs[0] eq '*' ) {
-            $filter = $self->make_filter( \@DNs ) or return;
-        }
-
+
+	my $filter;
+	unless ( $DNs[0] eq '*' ) {
+		$filter = $self->make_filter( \@DNs ) or return;
+	}
 
 	my $s = $self->search({ scope => 'one', filter => $filter });
@@ -1213,7 +1216,6 @@
 
 	# load it into an array for potential comparison
-	my @orig_ldif;
 	open LDIF, "$self->{'ldif_fname'}" or return;
-	@orig_ldif = <LDIF>;
+	my @orig_ldif = <LDIF>;
 	close LDIF;
 
@@ -1240,7 +1242,6 @@
 
 	# load changes into a new array for comparison
-	my @new_ldif;
 	open LDIF, "$self->{'ldif_fname'}" or return;
-	@new_ldif = <LDIF>;
+	my @new_ldif = <LDIF>;
 	close LDIF;
 
@@ -1251,10 +1252,11 @@
 		return if $line	 =~ /^\#/; # ignore comments
 		my ( $attr, $val ) = ( $1, $2 ) if $line =~ /^(.+?): (.*)$/;
+		return unless $attr;
 		return if index($attr, ':') != -1;  # ignore base64
 		return ( $attr, $val );
 	};
 
-	unwrap(\@orig_ldif);
-	unwrap(\@new_ldif);
+	unwrap( \@orig_ldif );
+	unwrap( \@new_ldif );
 
 	my $diff = Algorithm::Diff->new( \@orig_ldif, \@new_ldif );
@@ -1663,5 +1665,5 @@
 
 $0 = 'shelldap';
-my $VERSION = '0.2';
+my $VERSION = '0.3';
 
 use Getopt::Long;
