From: Peter M. <pet...@ma...> - 2002-10-10 17:01:14
|
Hi, please forget my previous mail. Here is a more correct version if the patch --- lib/Net/LDAP/LDIF.pm +++ lib/Net/LDAP/LDIF.pm Thu Oct 10 18:52:34 2002 @@ -85,8 +85,14 @@ chomp($ln); $self->{_current_lines} =3D $ln; chomp(@ldif =3D split(/^/, $ln)); - $self->{_next_lines} =3D scalar <$fh> || ''; - $self->eof(1) unless $self->{_next_lines}; + do { + $ln =3D scalar <$fh> || ''; + $self->eof(1) unless $ln; + $ln =3D~ s/\n //sg; + $ln =3D~ s/^#.*\n//mg; + chomp($ln); + $self->{_next_lines} =3D $ln; + } until ($self->{_next_lines} || $self->eof()); } @ldif; Yours Peter On Thursday 10 October 2002 12:06, Peter Marschall wrote: > Hi, > > currently Net::LDAP::LDIF from perl-ldap 0.26 cannot cope with > solitary comment lines between or after entries. > Comments that are adjacent to entries work fine. > > Here is an example: > > # sample LDIF > version: 1 > > dn: cn=3Dfoo,o=3Dbar > objectclass: top > objectclass: person > cn: foo > > # solitary comment (Net::LDAP::LDIF fails here) > > # adjacent comment > dn: cn=3Dbaz, o=3Dbar > objectclass: top > objectclass: person > cn: baz > > # another solitary comment (Net::LDAP::LDIF fails here too) > > # end of sample LDIF (Net::LDAP::LDIF fails here) > > > > The followoing patch to Net::LDAP::LDIF should make parsing the > example above possible > > --- LDIF.pm > +++ LDIF.pm Thu Oct 10 11:32:27 2002 > @@ -85,8 +85,13 @@ > chomp($ln); > $self->{_current_lines} =3D $ln; > chomp(@ldif =3D split(/^/, $ln)); > - $self->{_next_lines} =3D scalar <$fh> || ''; > - $self->eof(1) unless $self->{_next_lines}; > + do { > + $ln =3D scalar <$fh> || ''; > + $ln =3D~ s/\n //sg; > + $ln =3D~ s/^#.*\n//mg; > + $self->{_next_lines} =3D $ln; > + $self->eof(1) unless $self->{_next_lines}; > + } until ($self->eof() || $self->{_next_lines}); > } > > @ldif; > > Yours > Peter > > PS: Graham, the current version of perl-ldap according to the > perl-ldap.sf.net home page is still 0.25. --=20 Peter Marschall | eMail: pet...@ma... Scheffelstra=DFe 15 | pet...@is... 97072 W=FCrzburg | Tel: 0931/14721 PGP: D7 FF 20 FE E6 6B 31 74 D1 10 88 E0 3C FE 28 35 |