we need to unset LANG if we don't want to corrupt encoding
[virtual-ldap] / bin / ldap-rewrite.pl
index d3d8da0..23e790b 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 ],
+                               };
                        }
                }
 
@@ -154,6 +153,8 @@ sub run_proxy {
 }
 
 
+$ENV{LANG} = 'C'; # so we don't double-encode utf-8 if LANG is utf-8
+
 my $listenersock = IO::Socket::INET->new(
        Listen => 5,
        Proto => 'tcp',