Browse files

global overhaul: unquote identifiers used as hash keys

Get rid of quotes around identifiers in hash keys.
Rely on the "auto-quote" feature of the $hash{identifier}.
  • Loading branch information...
1 parent 0ab51ae commit 89ca579e0aa06fab6508e51632c2e7eb721f1039 @marschap marschap committed Dec 28, 2012
View
54 lib/Net/LDAP.pm
@@ -186,13 +186,13 @@ sub connect_ldaps {
# separate port from host overwriting given/default port
$host =~ s/^([^:]+|\[.*\]):(\d+)$/$1/ and $port = $2;
- $ldap->{'net_ldap_socket'} = IO::Socket::SSL->new(
+ $ldap->{net_ldap_socket} = IO::Socket::SSL->new(
PeerAddr => $host,
PeerPort => $port,
LocalAddr => $arg->{localaddr} || undef,
Proto => 'tcp',
Domain => $domain,
- Timeout => defined $arg->{'timeout'} ? $arg->{'timeout'} : 120,
+ Timeout => defined $arg->{timeout} ? $arg->{timeout} : 120,
_SSL_context_init_args($arg)
) or return undef;
@@ -207,52 +207,52 @@ sub _SSL_context_init_args {
my %verifycn_ctx = ();
my ($clientcert,$clientkey,$passwdcb);
- if (exists $arg->{'verify'}) {
- my $v = lc $arg->{'verify'};
+ if (exists $arg->{verify}) {
+ my $v = lc $arg->{verify};
$verify = 0 + (exists $ssl_verify{$v} ? $ssl_verify{$v} : $verify);
if ($verify) {
$verifycn_ctx{SSL_verifycn_scheme} = "ldap";
- $verifycn_ctx{SSL_verifycn_name} = $arg->{'sslserver'}
- if (defined $arg->{'sslserver'});
+ $verifycn_ctx{SSL_verifycn_name} = $arg->{sslserver}
+ if (defined $arg->{sslserver});
}
}
- if (exists $arg->{'clientcert'}) {
- $clientcert = $arg->{'clientcert'};
- if (exists $arg->{'clientkey'}) {
- $clientkey = $arg->{'clientkey'};
+ if (exists $arg->{clientcert}) {
+ $clientcert = $arg->{clientcert};
+ if (exists $arg->{clientkey}) {
+ $clientkey = $arg->{clientkey};
} else {
require Carp;
Carp::croak("Setting client public key but not client private key");
}
}
- if ($arg->{'checkcrl'} && !$arg->{'capath'}) {
+ if ($arg->{checkcrl} && !$arg->{capath}) {
require Carp;
Carp::croak("Cannot check CRL without having CA certificates");
}
- if (exists $arg->{'keydecrypt'}) {
- $passwdcb = $arg->{'keydecrypt'};
+ if (exists $arg->{keydecrypt}) {
+ $passwdcb = $arg->{keydecrypt};
}
# allow deprecated "sslv2/3" in addition to IO::Socket::SSL's "sslv23"
- if (defined $arg->{'sslversion'}) {
- $arg->{'sslversion'} =~ s:sslv2/3:sslv23:io;
+ if (defined $arg->{sslversion}) {
+ $arg->{sslversion} =~ s:sslv2/3:sslv23:io;
}
(
- SSL_cipher_list => defined $arg->{'ciphers'} ? $arg->{'ciphers'} : 'ALL',
- SSL_ca_file => exists $arg->{'cafile'} ? $arg->{'cafile'} : '',
- SSL_ca_path => exists $arg->{'capath'} ? $arg->{'capath'} : '',
+ SSL_cipher_list => defined $arg->{ciphers} ? $arg->{ciphers} : 'ALL',
+ SSL_ca_file => exists $arg->{cafile} ? $arg->{cafile} : '',
+ SSL_ca_path => exists $arg->{capath} ? $arg->{capath} : '',
SSL_key_file => $clientcert ? $clientkey : undef,
SSL_passwd_cb => $passwdcb,
- SSL_check_crl => $arg->{'checkcrl'} ? 1 : 0,
+ SSL_check_crl => $arg->{checkcrl} ? 1 : 0,
SSL_use_cert => $clientcert ? 1 : 0,
SSL_cert_file => $clientcert,
SSL_verify_mode => $verify,
- SSL_version => defined $arg->{'sslversion'} ? $arg->{'sslversion'} :
+ SSL_version => defined $arg->{sslversion} ? $arg->{sslversion} :
'sslv23',
%verifycn_ctx,
);
@@ -298,8 +298,8 @@ sub async {
my $ldap = shift;
@_
- ? ($ldap->{'net_ldap_async'},$ldap->{'net_ldap_async'} = shift)[0]
- : $ldap->{'net_ldap_async'};
+ ? ($ldap->{net_ldap_async},$ldap->{net_ldap_async} = shift)[0]
+ : $ldap->{net_ldap_async};
}
sub debug {
@@ -684,7 +684,7 @@ sub delete {
sub moddn {
my $ldap = shift;
my $arg = &_dn_options;
- my $del = $arg->{deleteoldrdn} || $arg->{'delete'} || 0;
+ my $del = $arg->{deleteoldrdn} || $arg->{delete} || 0;
my $newsup = $arg->{newsuperior};
my $mesg = $ldap->message('Net::LDAP::ModDN' => $arg);
@@ -696,7 +696,7 @@ sub moddn {
my $dn = $arg->{dn}
or return _error($ldap, $mesg, LDAP_PARAM_ERROR,"No DN specified");
- my $new = $arg->{newrdn} || $arg->{'new'}
+ my $new = $arg->{newrdn} || $arg->{new}
or return _error($ldap, $mesg, LDAP_PARAM_ERROR,"No NewRDN specified");
$mesg->encode(
@@ -973,8 +973,8 @@ sub schema {
my $base;
my $mesg;
- if (exists $arg{'dn'}) {
- $base = $arg{'dn'};
+ if (exists $arg{dn}) {
+ $base = $arg{dn};
}
else {
my $root = $self->root_dse( attrs => ['subschemaSubentry'] )
@@ -1071,7 +1071,7 @@ sub start_tls {
delete $ldap->{net_ldap_root_dse};
$arg->{sslversion} = 'tlsv1' unless defined $arg->{sslversion};
- $arg->{sslserver} = $ldap->{'net_ldap_host'} unless defined $arg->{sslserver};
+ $arg->{sslserver} = $ldap->{net_ldap_host} unless defined $arg->{sslserver};
IO::Socket::SSL::context_init( { _SSL_context_init_args($arg) } );
my $sock_class = ref($sock);
View
2 lib/Net/LDAP/Control.pm
@@ -85,7 +85,7 @@ sub new {
my $oid = (@_ & 1) ? shift : undef;
my %args = @_;
- $args{'type'} ||= $oid || $Pkg2Type{$pkg} || '';
+ $args{type} ||= $oid || $Pkg2Type{$pkg} || '';
unless ($args{type} =~ /^\d+(?:\.\d+)+$/) {
$args{error} = 'Invalid OID';
View
2 lib/Net/LDAP/Control/Sort.pm
@@ -86,7 +86,7 @@ sub order {
my @order = (@_ == 1) ? split(/\s+/, $_[0]) : @_;
- delete $self->{'value'};
+ delete $self->{value};
delete $self->{order};
delete $self->{error};
View
2 lib/Net/LDAP/Control/VLV.pm
@@ -16,7 +16,7 @@ sub init {
my($self) = @_;
# VLVREQUEST should always have a critical of true
- $self->{'critical'} = 1 unless exists $self->{'critical'};
+ $self->{critical} = 1 unless exists $self->{critical};
if (exists $self->{value}) {
$self->value($self->{value});
View
30 lib/Net/LDAP/Entry.pm
@@ -140,17 +140,17 @@ sub get_value {
sub changetype {
my $self = shift;
- return $self->{'changetype'} unless @_;
- $self->{'changes'} = [];
- $self->{'changetype'} = shift;
+ return $self->{changetype} unless @_;
+ $self->{changes} = [];
+ $self->{changetype} = shift;
return $self;
}
sub add {
my $self = shift;
- my $cmd = $self->{'changetype'} eq 'modify' ? [] : undef;
+ my $cmd = $self->{changetype} eq 'modify' ? [] : undef;
my $attrs = $self->{attrs} ||= _build_attrs($self);
while (my($type,$val) = splice(@_,0,2)) {
@@ -166,15 +166,15 @@ sub add {
}
- push(@{$self->{'changes'}}, 'add', $cmd) if $cmd;
+ push(@{$self->{changes}}, 'add', $cmd) if $cmd;
return $self;
}
sub replace {
my $self = shift;
- my $cmd = $self->{'changetype'} eq 'modify' ? [] : undef;
+ my $cmd = $self->{changetype} eq 'modify' ? [] : undef;
my $attrs = $self->{attrs} ||= _build_attrs($self);
while(my($type, $val) = splice(@_,0,2)) {
@@ -203,7 +203,7 @@ sub replace {
}
}
- push(@{$self->{'changes'}}, 'replace', $cmd) if $cmd;
+ push(@{$self->{changes}}, 'replace', $cmd) if $cmd;
return $self;
}
@@ -217,7 +217,7 @@ sub delete {
return;
}
- my $cmd = $self->{'changetype'} eq 'modify' ? [] : undef;
+ my $cmd = $self->{changetype} eq 'modify' ? [] : undef;
my $attrs = $self->{attrs} ||= _build_attrs($self);
while(my($type,$val) = splice(@_,0,2)) {
@@ -248,7 +248,7 @@ sub delete {
}
}
- push(@{$self->{'changes'}}, 'delete', $cmd) if $cmd;
+ push(@{$self->{changes}}, 'delete', $cmd) if $cmd;
return $self;
}
@@ -264,21 +264,21 @@ sub update {
$user_cb->(@_) if $user_cb };
if (ref($target) && UNIVERSAL::isa($target, 'Net::LDAP')) {
- if ($self->{'changetype'} eq 'add') {
+ if ($self->{changetype} eq 'add') {
$mesg = $target->add($self, 'callback' => $cb, %opt);
}
- elsif ($self->{'changetype'} eq 'delete') {
+ elsif ($self->{changetype} eq 'delete') {
$mesg = $target->delete($self, 'callback' => $cb, %opt);
}
- elsif ($self->{'changetype'} =~ /modr?dn/o) {
+ elsif ($self->{changetype} =~ /modr?dn/o) {
my @args = (newrdn => $self->get_value('newrdn') || undef,
deleteoldrdn => $self->get_value('deleteoldrdn') || undef);
my $newsuperior = $self->get_value('newsuperior');
push(@args, newsuperior => $newsuperior) if $newsuperior;
$mesg = $target->moddn($self, @args, 'callback' => $cb, %opt);
}
- elsif (@{$self->{'changes'}}) {
- $mesg = $target->modify($self, 'changes' => $self->{'changes'}, 'callback' => $cb, %opt);
+ elsif (@{$self->{changes}}) {
+ $mesg = $target->modify($self, 'changes' => $self->{changes}, 'callback' => $cb, %opt);
}
else {
require Net::LDAP::Message;
@@ -363,7 +363,7 @@ sub asn {
}
sub changes {
- my $ref = shift->{'changes'};
+ my $ref = shift->{changes};
$ref ? @$ref : ();
}
View
10 lib/Net/LDAP/FilterMatch.pm
@@ -170,13 +170,13 @@ sub _filterMatch($@)
if ($op eq 'substrings') {
$attr = $args->{type};
# build a regexp as assertion value
- $assertion = join('.*', map { "\Q$_\E" } map { values %$_ } @{$args->{'substrings'}});
- $assertion = '^'. $assertion if (exists $args->{'substrings'}[0]{'initial'});
- $assertion .= '$' if (exists $args->{'substrings'}[-1]{'final'});
+ $assertion = join('.*', map { "\Q$_\E" } map { values %$_ } @{$args->{substrings}});
+ $assertion = '^'. $assertion if (exists $args->{substrings}[0]{initial});
+ $assertion .= '$' if (exists $args->{substrings}[-1]{final});
}
else {
- $attr = $args->{'attributeDesc'};
- $assertion = $args->{'assertionValue'}
+ $attr = $args->{attributeDesc};
+ $assertion = $args->{assertionValue}
}
my @values = $entry->get_value($attr);
View
2 lib/Net/LDAP/Intermediate.pm
@@ -38,7 +38,7 @@ sub new {
my $responseName = (@_ & 1) ? shift : undef;
my %args = @_;
- $args{'responseName'} ||= $responseName || $Class2ResponseName{$class} || '';
+ $args{responseName} ||= $responseName || $Class2ResponseName{$class} || '';
unless ($args{responseName} =~ /^\d+(?:\.\d+)+$/) {
$args{error} = 'Invalid responseName';
View
50 lib/Net/LDAP/LDIF.pm
@@ -52,16 +52,16 @@ sub new {
}
# Default the encoding of DNs to 'none' unless the user specifies
- $opt{'encode'} = 'none' unless exists $opt{'encode'};
+ $opt{encode} = 'none' unless exists $opt{encode};
# Default the error handling to die
- $opt{'onerror'} = 'die' unless exists $opt{'onerror'};
+ $opt{onerror} = 'die' unless exists $opt{onerror};
# sanitize options
- $opt{'lowercase'} ||= 0;
- $opt{'change'} ||= 0;
- $opt{'sort'} ||= 0;
- $opt{'version'} ||= 0;
+ $opt{lowercase} ||= 0;
+ $opt{change} ||= 0;
+ $opt{sort} ||= 0;
+ $opt{version} ||= 0;
my $self = {
changetype => "modify",
@@ -86,7 +86,7 @@ sub new {
sub _read_lines {
my $self = shift;
- my $fh = $self->{'fh'};
+ my $fh = $self->{fh};
my @ldif = ();
my $entry = '';
my $in_comment = 0;
@@ -180,7 +180,7 @@ sub _read_entry {
}
if (@ldif and $ldif[0] =~ /^version:\s+(\d+)/) {
- $self->{'version'} = $1;
+ $self->{version} = $1;
shift @ldif;
return $self->_read_entry
unless @ldif;
@@ -213,7 +213,7 @@ sub _read_entry {
if ((scalar @ldif) && ($ldif[0] =~ /^changetype:\s*/)) {
my $changetype = $ldif[0] =~ s/^changetype:\s*//
- ? shift(@ldif) : $self->{'changetype'};
+ ? shift(@ldif) : $self->{changetype};
$entry->changetype($changetype);
return $entry if ($changetype eq "delete");
@@ -224,7 +224,7 @@ sub _read_entry {
}
while(@ldif) {
- my $modify = $self->{'modify'};
+ my $modify = $self->{modify};
my $modattr;
my $lastattr;
if($changetype eq "modify") {
@@ -352,7 +352,7 @@ sub _read_entry {
sub read_entry {
my $self = shift;
- unless ($self->{'fh'}) {
+ unless ($self->{fh}) {
$self->_error("LDIF file handle not valid");
return;
}
@@ -476,8 +476,8 @@ sub write_version {
my $self = shift;
my $res = 1;
- $res &&= print "version: $self->{'version'}\n"
- if ($self->{'version'} && !$self->{version_written}++);
+ $res &&= print "version: $self->{version}\n"
+ if ($self->{version} && !$self->{version_written}++);
return $res;
}
@@ -487,19 +487,19 @@ sub _write_entry {
my $self = shift;
my $change = shift;
my $entry;
- my $wrap = int($self->{'wrap'});
- my $lower = $self->{'lowercase'};
- my $sort = $self->{'sort'};
+ my $wrap = int($self->{wrap});
+ my $lower = $self->{lowercase};
+ my $sort = $self->{sort};
my $res = 1; # result value
local($\,$,); # output field and record separators
- unless ($self->{'fh'}) {
+ unless ($self->{fh}) {
$self->_error("LDIF file handle not valid");
return;
}
- my $saver = SelectSaver->new($self->{'fh'});
+ my $saver = SelectSaver->new($self->{fh});
- my $fh = $self->{'fh'};
+ my $fh = $self->{fh};
foreach $entry (@_) {
unless (ref $entry) {
$self->_error("Entry '$entry' is not a valid Net::LDAP::Entry object.");
@@ -516,7 +516,7 @@ sub _write_entry {
$res &&= $self->write_version() unless $self->{write_count}++;
$res &&= print "\n";
- $res &&= _write_dn($entry->dn,$self->{'encode'},$wrap);
+ $res &&= _write_dn($entry->dn,$self->{encode},$wrap);
$res &&= print "changetype: $type\n";
@@ -544,20 +544,20 @@ sub _write_entry {
}
my $i = 0;
while ($i < @$chg) {
- $res &&= print "-\n" if (!$self->{'version'} && $dash++);
+ $res &&= print "-\n" if (!$self->{version} && $dash++);
my $attr = $chg->[$i++];
my $val = $chg->[$i++];
$res &&= print $type,": ",$attr,"\n";
$res &&= _write_attr($attr,$val,$wrap,$lower);
- $res &&= print "-\n" if ($self->{'version'});
+ $res &&= print "-\n" if ($self->{version});
}
}
}
else {
$res &&= $self->write_version() unless $self->{write_count}++;
$res &&= print "\n";
- $res &&= _write_dn($entry->dn,$self->{'encode'},$wrap);
+ $res &&= _write_dn($entry->dn,$self->{encode},$wrap);
$res &&= _write_attrs($entry,$wrap,$lower,$sort);
}
}
@@ -665,8 +665,8 @@ sub current_lines {
sub version {
my $self = shift;
- return $self->{'version'} unless @_;
- $self->{'version'} = shift || 0;
+ return $self->{version} unless @_;
+ $self->{version} = shift || 0;
}
sub next_lines {
View
2 lib/Net/LDAP/Message.pm
@@ -150,7 +150,7 @@ sub decode { # $self, $pdu, $control
if (defined $self->{callback}) {
$self->{callback}->($self, $intermediate);
} else {
- push(@{$self->{'intermediate'} ||= []}, $intermediate);
+ push(@{$self->{intermediate} ||= []}, $intermediate);
}
return $self;
View
6 lib/Net/LDAP/Schema.pm
@@ -89,7 +89,7 @@ sub parse {
sub dump {
my $self = shift;
my $fh = @_ ? shift : \*STDOUT;
- my $entry = $self->{'entry'} or return;
+ my $entry = $self->{entry} or return;
require Net::LDAP::LDIF;
Net::LDAP::LDIF->new($fh,"w", wrap => 0)->write($entry);
1;
@@ -447,10 +447,10 @@ sub matchingrule_for_attribute {
my $attrtype = $self->attribute( $attr );
if (exists $attrtype->{$matchtype}) {
return $attrtype->{$matchtype};
- } elsif (exists $attrtype->{'sup'}) {
+ } elsif (exists $attrtype->{sup}) {
# the assumption is that all superiors result in the same ruleset
return $self->matchingrule_for_attribute(
- $attrtype->{'sup'}[0],
+ $attrtype->{sup}[0],
$matchtype);
}
return undef;
View
12 lib/Net/LDAP/Search.pm
@@ -24,8 +24,8 @@ sub first_entry { # compat
sub next_entry { # compat
my $self = shift;
- $self->entry( defined $self->{'CurrentEntry'}
- ? $self->{'CurrentEntry'} + 1
+ $self->entry( defined $self->{CurrentEntry}
+ ? $self->{CurrentEntry} + 1
: 0);
}
@@ -59,7 +59,7 @@ sub decode {
}
elsif ($data = delete $result->{protocolOp}{searchResRef}) {
- push(@{$self->{'reference'} ||= []}, @$data);
+ push(@{$self->{reference} ||= []}, @$data);
$self->{callback}->($self, bless $data, 'Net::LDAP::Reference')
if (defined $self->{callback});
@@ -147,14 +147,14 @@ sub references {
$self->sync unless exists $self->{resultCode};
- return unless exists $self->{'reference'} && ref($self->{'reference'});
+ return unless exists $self->{reference} && ref($self->{reference});
- @{$self->{'reference'} || []}
+ @{$self->{reference} || []}
}
sub as_struct {
my $self = shift;
- my %result = map { ( $_->dn, ($_->{'attrs'} || $_->_build_attrs) ) } entries($self);
+ my %result = map { ( $_->dn, ($_->{attrs} || $_->_build_attrs) ) } entries($self);
return \%result;
}

0 comments on commit 89ca579

Please sign in to comment.