Permalink
Browse files

Decode UTF-8 right.

  • Loading branch information...
1 parent d8ced48 commit 39327d1b5d2e2cbf6843889bf2237d593c1c4ff4 Dave Lambley committed Dec 14, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/Net/LDAP/Util.pm
View
@@ -31,6 +31,8 @@ the L<Net::LDAP> modules.
=cut
+use Encode qw/ encode decode /;
+
use vars qw($VERSION);
require Exporter;
require Net::LDAP::Constant;
@@ -562,7 +564,8 @@ sub escape_dn_value(@)
{
my @values = @_;
- map { $_ =~ s/([\\",=+<>#;])/\\$1/og;
+ map { $_=encode('utf-8', $_);
+ $_ =~ s/([\\",=+<>#;])/\\$1/og;
$_ =~ s/([\x00-\x1F])/"\\".unpack("H2",$1)/oge;
$_ =~ s/(^\s+|\s+$)/"\\20" x length($1)/oge; } @values;
@@ -591,7 +594,9 @@ my @values = @_;
map { $_ =~ s/\\([\\",=+<>#;]|[0-9a-fA-F]{2})
/(length($1)==1) ? $1 : pack("H2",$1)
- /ogex; } @values;
+ /ogex;
+ $_ = decode('utf-8', $_);
+ } @values;
return(wantarray ? @values : $values[0]);
}

0 comments on commit 39327d1

Please sign in to comment.