Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 21, 2012
@marschap marschap Util.pm: extend ldap_explode_dn() for RFC 4514
Extend ldap_explode_dn() to also parse DNs that conform to RFC 4514.

This way ldap_explode_dn() is rather lax in checking what it allows or not,
but tries to make sense of as much DNs as possible.

Changes:
  - only spaces ignored around attribute value instead of \s
  - NUL (U+0000) not allowed unquoted in attribute value
  - sharp/square/octothorpe (U+0023) allowed unquoted unless at first position
  - equal sign (U+003D) allowed unquoted in attribute value
  - space (U+0020) allowed to be quoted by \\ in a quoted pair

Test cases adapted accordingly.
2943868
Commits on Sep 28, 2012
@marschap marschap LDAP.pm: don't try to set errors on undefined objects
When disconnecting, make sure the set_error() method is called only
on defined objects

Author: Howard Wilkinson <howard@orb-it.net>

Originally sent in via private mail to Graham Barr:

 Date: 20.06.2012 13:06
 From: Howard Wilkinson <howard@orb-it.net>
 To: gbarr <gbarr@pobox.com>
 Reply to: howard@cohtech.com

 Graham,

 [...]

 However, the DESTROY is still being called and killing the error
 messages - so this could do with being added to the package.

 --- LDAP.pm~    2012-06-20 12:02:36.000000000 +0100
 +++ LDAP.pm     2012-06-20 12:03:01.000000000 +0100
 @@ -902,6 +902,7 @@

   if (my $msgs = delete $self->{net_ldap_mesg}) {
     foreach my $mesg (values %$msgs) {
 +     next unless (defined $mesg);
       $mesg->set_error($err, $etxt);
     }
   }

 [...]

 Howard.
0e5156b
@marschap marschap LDAPI.pm: document environment variable LDAPI_SOCK and default 3b170b8
View
1  lib/Net/LDAP.pm
@@ -920,6 +920,7 @@ sub _drop_conn {
if (my $msgs = delete $self->{net_ldap_mesg}) {
foreach my $mesg (values %$msgs) {
+ next unless (defined $mesg);
$mesg->set_error($err, $etxt);
}
}
View
22 lib/Net/LDAP/Util.pm
@@ -427,28 +427,32 @@ sub ldap_explode_dn($%) {
return undef unless defined $dn;
return [] if $dn eq '';
+ my $pair = qr/\\(?:[\\"+,;<> #=]|[0-9A-F]{2})/i;
+
my (@dn, %rdn);
while (
$dn =~ /\G(?:
\s*
- ([a-zA-Z][-a-zA-Z0-9]*|(?:[Oo][Ii][Dd]\.)?\d+(?:\.\d+)*)
+ ((?i)[A-Z][-A-Z0-9]*|(?:oid\.)?\d+(?:\.\d+)*) # attribute type
\s*
=
- \s*
- (
- (?:[^\\",=+<>\#;]*[^\\",=+<>\#;\s]|\s*\\(?:[\\ ",=+<>#;]|[0-9a-fA-F]{2}))*
+ [ ]*
+ ( # attribute value
+ (?:(?:[^\x00 "\#+,;<>\\\x80-\xBF]|$pair) # string
+ (?:(?:[^\x00"+,;<>\\]|$pair)*
+ (?:[^\x00 "+,;<>\\]|$pair))?)?
|
- \#(?:[0-9a-fA-F]{2})+
+ \#(?:[0-9a-fA-F]{2})+ # hex string
|
- "(?:[^\\"]+|\\(?:[\\",=+<>#;]|[0-9a-fA-F]{2}))*"
+ "(?:[^\\"]+|$pair)*" # "-quoted string, only for v2
)
- \s*
- (?:([;,+])\s*(?=\S)|$)
+ [ ]*
+ (?:([;,+])\s*(?=\S)|$) # separator
)\s*/gcx)
{
my($type,$val,$sep) = ($1,$2,$3);
- $type =~ s/^oid\.(\d+(\.\d+)*)$/$1/i; #remove leading "oid."
+ $type =~ s/^oid\.//i; #remove leading "oid."
if ( !$opt{casefold} || $opt{casefold} eq 'upper' ) {
$type = uc $type;
View
8 lib/Net/LDAPI.pm
@@ -49,8 +49,12 @@ object; see L<Net::LDAP> for details.
=item new ( [SOCKPATH] )
Create a new connection. SOCKPATH can optionally be specified, to
-specify the location of the UNIX domain socket to connect to. See
-L<Net::LDAP/new> for details.
+specify the location of the UNIX domain socket to connect to.
+
+If SOCKPATH is not given, the environment variable C<LDAPI_SOCK> is evaluated,
+and if that does not exist, the value C</var/run/ldapi> is used.
+
+See L<Net::LDAP/new> for further details.
=back
View
4 t/01canon_dn.t
@@ -69,7 +69,9 @@ same OU = Sales+CN =J. Smith,O= Widget Inc.,C=US
same OU="Sales"+CN=J. Smith,O=Widget Inc.,C=US
diff OU="Sales+CN=J. Smith",O=Widget Inc.,C=US
-bad cn=J.\20Smith\+ou=Sales,O=Widget\20Inc.,C=US
+ref cn=J.\20Smith\+ou=Sales,O=Widget\20Inc.,C=US
+
+ref cn=Clerk #1\+ou=Sales,O=Widget\20Inc.,C=US
ref CN=Babs Jensen,O=Widget Inc.,C=US
same cn=Babs Jensen,o=Widget Inc.,c=US

No commit comments for this range

Something went wrong with that request. Please try again.