bugSTUMP - Bugs: bug #59279, Bad e-mail regexps


You are not allowed to post comments on this tracker with your current authentication level.

bug #59279: Bad e-mail regexps

Submitter:  Tristan Miller <psychonaut>
Submitted:  Fri 16 Oct 2020 09:38:42 AM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  rayner
Open/Closed:  Closed Planned Release:  None

Sat 17 Apr 2021 12:29:37 AM UTC, comment #2: 

Fixed, apart from updating the documentation, which is a whole other thing to figure out. Have raised bug #60405 for dealing with that and assigned it to myself.

Rayner Lucas <rayner>
Group administrator
Fri 16 Apr 2021 03:31:38 AM UTC, comment #1: 

Looks like the intent is to extract just the e-mail address from the From: line, but as you say, it won't match all valid e-mail addresses, and doesn't quite work as it was probably intended to.

I also think there's a minor bug elsewhere in suspicious.pl: the log line that it writes to STDERR will read "...from From: username@domain.name"

There are at least three actively maintained Perl packages for parsing e-mail addresses. I'm using Email::Address as it doesn't require any other packages.

I'll re-check my code tomorrow and then merge the changes.

Rayner Lucas <rayner>
Group administrator
Fri 16 Oct 2020 09:38:42 AM UTC, original submission:  

The scripts processNoack.pl and suspicious.pl look like they are using regexps to parse e-mail addresses.  For example:

if ($From =~ m/([\w-\.]+)@([\w-\.]*)[^\w-\.]/){
    $From = "From: $1\@$2";}

These regexps are bad for two reasons:

(1) They are syntactically incorrect -- I think Perl is trying to interpret [\w-\.] as a character range, but it's nonsensical to use \w as one of the endpoints.  Probably what was meant was [-\w\.].

(2) They are oversimplified and will not reliably detect all valid e-mail addresses.

There is almost certainly some standard package in Perl that can be used to correctly parse an e-mail address.  Failing that, we could always use a "proper" regexp such as the one described in this Stack Overflow post.

Tristan Miller <psychonaut>
Group administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rayner (Posted a comment)
  • -email is unavailable- added by psychonaut (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.


    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-04-17 rayner StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2021-04-16 rayner StatusNone In Progress

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code