Item12365: Wrong encoding when accessing AD from utf-8 Foswiki

pencil
Priority: Normal
Current State: Closed
Released In: n/a
Target Release:
Applies To: Extension
Component: LdapContrib, LdapNgPlugin
Branches: trunk
Reported By: MartinKaufmann
Waiting For:
Last Change By: MichaelDaum
When using Foswiki (with {Site}{CharSet} set to utf-8) to access an Active Directory server (with {Ldap}{CharSet} set to utf-8), the resulting data is not correctly encoded, i.e. special characters are not displayed properly (just showing a question mark). By removing the deconding step, this can be fixed (but of course it will not working for other encodings):

--- Core.pm.orig        2012-11-29 11:03:32.000000000 +0100
+++ Core.pm     2013-01-22 12:12:12.000000000 +0100
@@ -175,7 +175,8 @@
       if ($blobAttrs{$attr}) {
         $data{$attr} = $ldap->cacheBlob($entry, $attr, $theRefresh);
       } else {
-        $data{$attr} = $ldap->fromLdapCharSet($entry->get_value($attr));
+        #$data{$attr} = $ldap->fromLdapCharSet($entry->get_value($attr));
+        $data{$attr} = $entry->get_value($attr);
       }
     }
     push @results, expandVars($theFormat, %data);
@@ -422,7 +423,7 @@
     next unless defined $value && $value ne '';

     # SMELL: do we need to encode it to utf-8?
-    $value = Encode::decode($ldapCharSet, $value);
+    #$value = Encode::decode($ldapCharSet, $value);

     my $label = $personAttributes->{$attr};
     #print STDERR "$label: $value\n";

-- MartinKaufmann - 22 Jan 2013

The same holds true for LdapContrib. The WikiNames are not translated properly (broken umlaut etc) unless the decoding is commented out:

--- LdapContrib.pm.orig 2012-12-13 15:56:15.000000000 +0100
+++ LdapContrib.pm      2013-01-24 16:14:01.000000000 +0100
@@ -1222,7 +1222,7 @@
         next unless $value;
         $value =~ s/^\s+//o;
         $value =~ s/\s+$//o;
-        $value = $this->fromLdapCharSet($value);
+        #$value = $this->fromLdapCharSet($value);
         #writeDebug("$attr=$value");
         push @wikiName, $value;
       }

-- MartinKaufmann - 24 Jan 2013

This has been fixed in fromLdapCharSet directly not to recode chars if both encodings are the same.

-- MichaelDaum - 18 Mar 2014
 
Topic revision: r6 - 18 Mar 2014, MichaelDaum
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy