aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema')
-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;
}