From 28efba729bbd2687016cf122c1b01c2e8b09c202 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sat, 26 Jan 2013 18:12:01 +0100 Subject: Bugfix. --- lib/Fripost/Schema/Domain.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/Fripost/Schema/Domain.pm') diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm index ce7b900..44ad84e 100644 --- a/lib/Fripost/Schema/Domain.pm +++ b/lib/Fripost/Schema/Domain.pm @@ -17,8 +17,8 @@ use warnings; use utf8; use parent 'Fripost::Schema'; -use Fripost::Schema::Util qw/must_attrs softdie canonical_dn dn2mail email_valid - ldap_explode_dn ldap_error ldap_and_filter/; +use Fripost::Schema::Util qw/softdie dn2mail email_valid domain_valid + canonical_dn ldap_explode_dn ldap_error/; use Fripost::Schema::Mail; use Net::IDN::Encode qw/domain_to_ascii domain_to_unicode email_to_unicode/; use URI::Escape::XS 'encodeURIComponent'; @@ -204,10 +204,11 @@ sub search { : [ '1.1' ]; } + my $filter = Fripost::Schema::Util::ldap_and_filter(@filters); my $domains = $self->ldap->search( base => canonical_dn(@{$self->suffix}) , scope => 'one' , deref => 'never' - , filter => ldap_and_filter(@filters) + , filter => $filter , attrs => $attrs ); ldap_error($domains, %options) // return; @@ -679,7 +680,8 @@ sub replace { # Nothing to do after an error. return if $options{'-error'} && ${$options{'-error'}}; - &_is_valid($domain, %options); + # Check domain validity. + &_is_valid($domain, %options) // return; return 1 if $options{'-dry-run'}; my %entry = $self->_domain_to_entry (%$domain); @@ -695,10 +697,8 @@ sub _is_valid { my $d = shift; my %options = @_; eval { - must_attrs( $d, qw/name isActive/ ); - $d->{name} = email_valid( $d->{name}, -prefix => 'fake@', - -error => 'Invalid domain', - -exact => 1 ); + Fripost::Schema::Util::must_attrs( $d, qw/name isActive/ ); + $d->{name} = domain_valid( $d->{name} ); $d->{catchAlls} = [ map { email_valid($_, -prefix => 'fake') } @{$d->{catchAlls}} ] if $d->{catchAlls}; -- cgit v1.2.3