Skip to content

Commit 8c4a701

Browse files
committed
Bug 1202461 - backport bug 319953 to bmo (Missing real email syntax check)
1 parent ea60d00 commit 8c4a701

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Bugzilla/Util.pm

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,12 +704,22 @@ sub generate_random_password {
704704
sub validate_email_syntax {
705705
my ($addr) = @_;
706706
my $match = Bugzilla->params->{'emailregexp'};
707-
my $ret = ($addr =~ /$match/ && $addr !~ /[\\\(\)<>&,;:"\[\] \t\r\n\P{ASCII}]/);
708-
if ($ret) {
707+
my $email = $addr . Bugzilla->params->{'emailsuffix'};
708+
# This regexp follows RFC 2822 section 3.4.1.
709+
my $addr_spec = $Email::Address::addr_spec;
710+
# RFC 2822 section 2.1 specifies that email addresses must
711+
# be made of US-ASCII characters only.
712+
# Email::Address::addr_spec doesn't enforce this.
713+
if ($addr =~ /$match/
714+
&& $email !~ /\P{ASCII}/
715+
&& $email =~ /^$addr_spec$/
716+
&& length($email) <= 127)
717+
{
709718
# We assume these checks to suffice to consider the address untainted.
710719
trick_taint($_[0]);
720+
return 1;
711721
}
712-
return $ret ? 1 : 0;
722+
return 0;
713723
}
714724

715725
sub validate_date {

0 commit comments

Comments
 (0)