mark sockets as binary so we don't corrupt encoding
[virtual-ldap] / bin / ldap-rewrite.pl
index d3d8da0..4e2d55e 100755 (executable)
@@ -108,12 +108,11 @@ sub log_response {
                        foreach my $type ( keys %$data ) {
 
                                my $vals = $data->{$type};
-                               $vals =~ s{#\s*$}{};
-                               
-                               my @vals = split(/\s*#\s*/, $vals);
 
-                               push @{ $response->{protocolOp}->{searchResEntry}->{attributes} },
-                                       { type => $config->{overlay_prefix} . $type, vals => [ @vals ] };
+                               push @{ $response->{protocolOp}->{searchResEntry}->{attributes} }, {
+                                       type => $config->{overlay_prefix} . $type,
+                                       vals => ref($vals) eq 'ARRAY' ? $vals : [ $vals ],
+                               };
                        }
                }
 
@@ -132,6 +131,10 @@ sub run_proxy {
        die "Could not create listener socket: $!\n" unless $listenersock;
        die "Could not create connection to server: $!\n" unless $targetsock;
 
+       # mark sockets as binary
+       binmode( $listenersock );
+       binmode( $targetsock );
+
        my $sel = IO::Select->new($listenersock);
        my %Handlers;
        while (my @ready = $sel->can_read) {