From 6ae4afa16e107d99936890874fe609b87ecfa1f2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 27 Apr 2005 21:26:39 +0000 Subject: [PATCH] Regexp in wfQuotedPrintable_name_and_emailaddr is wrong and sometimes fails under conditions not fully explored. Should be removed and replaced with cleaner interface, probably. In the meantime, wrapping in a check and adding some debug statements. --- includes/UserMailer.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 80eb445c72..035e94a1e0 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -54,10 +54,15 @@ require_once( 'WikiError.php' ); function wfQuotedPrintable_name_and_emailaddr( $string ) { /* do not quote printable for email address string , but only for the (leading) string, usually the name */ - preg_match( '/^([^<]*)?(<([A-z0-9_.-]+([A-z0-9_.-]+)*\@[A-z0-9_-]+([A-z0-9_.-]+)*([A-z.]{2,})+)>)?$/', $string, $part ); - if ( !isset($part[1]) ) return $part[2]; - if ( !isset($part[2]) ) return wfQuotedprintable($part[1]); - return wfQuotedprintable($part[1]) . $part[2] ; + if( preg_match( '/^([^<]*)?(<([A-z0-9_.-]+([A-z0-9_.-]+)*\@[A-z0-9_-]+([A-z0-9_.-]+)*([A-z.]{2,})+)>)?$/', $string, $part ) ) { + wfDebug( "wfQuotedPrintable_name_and_emailaddr: '$string' " . serialize( $part ) . "\n" ); + if ( !isset($part[2]) ) return wfQuotedprintable($part[1]); + return wfQuotedprintable($part[1]) . $part[2] ; + } else { + # What have we been given?? + wfDebug( "wfQuotedPrintable_name_and_emailaddr: got confused by '$string'\n" ); + return wfQuotedprintable( $string ); + } } /** -- 2.20.1