aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-09 03:33:09 +0200
committerGuilhem Moulin <guilhem.moulin@fripost.org>2012-09-09 03:33:09 +0200
commit42c3fc18e894841e6578b5814405b41946b64639 (patch)
tree2fe2317ed655d3feb9410a20d285be70af643b57 /lib
parenta2df8385c36f166d65a447aab4e081961abad5a2 (diff)
wibble
Diffstat (limited to 'lib')
-rw-r--r--lib/Fripost/Schema/Domain.pm3
-rw-r--r--lib/Fripost/Schema/Misc.pm5
2 files changed, 5 insertions, 3 deletions
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;
}