Skip to content

Commit

Permalink
LDIF.pm: when reading, allow control values to be absent
Browse files Browse the repository at this point in the history
This should fix the case for controls without values.
For controls with values, correctly strip leadin space.
  • Loading branch information
marschap committed Mar 29, 2014
1 parent 2a0a6cc commit 8aee149
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/Net/LDAP/LDIF.pm
Expand Up @@ -227,13 +227,20 @@ sub _read_entry {

if ($control =~ /^control:\s*(\d+(?:\.\d+)*)(?:\s+(true|false))?(?:\s*\:(.*))?$/) {
my($oid,$critical,$value) = ($1,$2,$3);
my $type = $1 if (defined($value) && $value =~ s/^([\<\:])\s*//);

$critical = ($critical && $critical =~ /true/) ? 1 : 0;

$value = $self->_read_attribute_value($type, $value, @ldif)
if (defined($value) && $type);
return if !defined($value);
if (defined($value)) {
my $type = $1 if ($value =~ s/^([\<\:])\s*//);

$value =~ s/^\s*//;

if ($type) {
$value = $self->_read_attribute_value($type, $value, @ldif);
return $self->_error('Illegal value in control line given', @ldif)
if !defined($value);
}
}

require Net::LDAP::Control;
my $ctrl = Net::LDAP::Control->new(type => $oid,
Expand Down

0 comments on commit 8aee149

Please sign in to comment.