Greetings,

Just came across a minor (but annoying) bug in the documentation.

The following extract :

"CONSTRUCTOR
encode => 'none' | 'canonical' | 'base64'
Some values in LDIF cannot be written verbatim and have to be
encoded in some way:


            'none'
                The default.

            'canonical'
                See "canonical_dn" in Net::LDAP::Util.

            'base64'
                Use base64."

would lead you to believe that the 'encode' flag applies to all objects, when in fact it applies only to the DN.

from version 0.15

348 sub _write_attr {
349   my($attr,$val,$wrap,$lower) = @_;
350   my $v;
351   my $res = 1;      # result value
352   foreach $v (@$val) {
353     my $ln = $lower ? lc $attr : $attr;
354     if ($v =~ /(^[ :]|[\x00-\x1f\x7f-\xff])/) {
355       require MIME::Base64;
356       $ln .= ":: " . MIME::Base64::encode($v,"");
357     }
358     else {
359       $ln .= ": " . $v;
360     }
361     $res &&= print _wrap($ln,$wrap),"\n";
362   }
363   $res;
364 }

makes no reference to the encode flag, while :

385 sub _write_dn {
386 my($dn,$encode,$wrap) = @_;
387 if ($dn =~ /^[ :<]|[\x00-\x1f\x7f-\xff]/) {
388 if ($encode =~ /canonical/i) {
389 require Net::LDAP::Util;
390 $dn = Net::LDAP::Util::canonical_dn($dn);
391 # Canonicalizer won't fix leading spaces, colons or less-thans, which
392 # are special in LDIF, so we fix those up here.
393 $dn =~ s/^([ :<])/\\$1/;
394 } elsif ($encode =~ /base64/i) {
395 require MIME::Base64;
396 $dn = "dn:: " . MIME::Base64::encode($dn,"");
397 } else {
398 $dn = "dn: $dn";


is the only place I was able to find a reference to the use of the encode flag value.

I think that either the encode flag needs to be renamed encodedn (none|base64|canonical) and the encode flag redirected to apply to attribute values, but that would break a lot of existing code. Alternatively, checking the encode flag globally would put the code back in sync with the documentation.

Comments ?

Erik



Reply via email to