Ticket #5169: wp-mail.php.3.diff

File wp-mail.php.3.diff, 0.8 kB (added by Bobcat, 1 year ago)

Isolates email addr before sanitizing (fixed typo in comment)

  • wp-mail.php

    old new  
    6060                                $subject = $subject[0]; 
    6161                        } 
    6262 
    63                         // Set the author using the email address (To or Reply-To, the last used) 
     63                        // Set the author using the email address (From or Reply-To, the last used) 
    6464                        // otherwise use the site admin 
    6565                        if ( preg_match('/(From|Reply-To): /', $line) )  { 
    66                                 $author = sanitize_email(preg_replace('/(From|Reply-To): /', '', $line)); 
     66                                if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) ) 
     67                                        $author = $matches[0]; 
     68                                else 
     69                                        $author = trim($line); 
     70                                $author = sanitize_email($author); 
    6771                                if ( is_email($author) ) { 
    6872                                        echo "Author = {$author} <p>"; 
    6973                                        $author = $wpdb->escape($author);