X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=blobdiff_plain;f=email.php;h=74518ab17b95c461df87ce23f50527208ceb71fa;hp=a7c841dd88f1ad5c5c1de49366479c9930f104c3;hb=HEAD;hpb=6e1e6239e46cb1c3059f4acd89cc53bf628cf99c diff --git a/email.php b/email.php index a7c841d..74518ab 100644 --- a/email.php +++ b/email.php @@ -1,23 +1,9 @@ $', $addr) !== false) { + if(preg_match('|<.*>$|', $addr) === 1) { # format 2 $div = strrpos($addr, '<'); $name = substr($addr, 0 , $div); @@ -86,7 +71,7 @@ function email_header($addr) { $email = substr($addr, $div + 1, -1); } else { $email = $addr; - $name = ereg_replace('@.*', '', $addr); + $name = preg_replace('|@.*|', '', $addr); } if(!valid_email($email)) { @@ -94,7 +79,7 @@ function email_header($addr) { } #FIXME should allow many more characters here - $name = ereg_replace("[^a-zA-Z0-9 _'.-]", '_', $name); + $name = preg_replace("|[^a-z0-9 _/'.-]|i", '_', $name); return $name . ' <' . $email . '>'; } @@ -103,5 +88,5 @@ function email_header($addr) { # return true if e-mail is formatted like a valid email address function valid_email($email) { - return ereg('^[0-9a-zA-Z_~.-]+@[0-9a-zA-Z.-]+\.[a-z]+$', $email) !== false; + return preg_match('|^[0-9a-zA-Z_~.+-]+@[0-9a-zA-Z.-]+\.[a-z]+$|', $email) === 1; }