From 42c3fc18e894841e6578b5814405b41946b64639 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 9 Sep 2012 03:33:09 +0200 Subject: wibble --- lib/Fripost/Schema/Domain.pm | 3 ++- lib/Fripost/Schema/Misc.pm | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/Fripost/Schema') diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm index 3ff2c25..e1b855f 100644 --- a/lib/Fripost/Schema/Domain.pm +++ b/lib/Fripost/Schema/Domain.pm @@ -159,7 +159,8 @@ sub _is_valid { must_attrs( $d, qw/domain isactive/ ); email_valid( $d->{domain}, -prefix => 'fake@', -error => 'Invalid domain', -exact => 1 ); - $d->{catchalls} = [ map { email_valid($_) } @{$d->{catchalls}} ]; + $d->{catchalls} = [ map { email_valid($_, -prefix => 'fake') } + @{$d->{catchalls}} ]; } diff --git a/lib/Fripost/Schema/Misc.pm b/lib/Fripost/Schema/Misc.pm index be88385..384f919 100644 --- a/lib/Fripost/Schema/Misc.pm +++ b/lib/Fripost/Schema/Misc.pm @@ -96,9 +96,9 @@ sub email_valid { my %options = @_; my $i = $in; - $i =~ s/.*<([^>]+)>.*/$1/; + $i =~ s/^[^<>]+\s<([^>]+)>/$1/; my $mesg = $options{'-error'} // "Invalid e-mail"; - $in = $options{'-prefix'}.$in if defined $options{'-prefix'}; + $in = $options{'-prefix'}.$i if defined $options{'-prefix'}; my $addr = Email::Valid::->address( -address => $in, -tldcheck => 1, @@ -106,6 +106,7 @@ sub email_valid { my $match = defined $addr; $match &&= $addr eq $in if $options{'-exact'}; die $mesg." ‘".$i."‘\n" unless $match; + $addr =~ s/^$options{'-prefix'}// if defined $options{'-prefix'}; return $addr; } -- cgit v1.2.3