Regexp in wfQuotedPrintable_name_and_emailaddr is wrong and sometimes fails under...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Apr 2005 21:26:39 +0000 (21:26 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 27 Apr 2005 21:26:39 +0000 (21:26 +0000)
includes/UserMailer.php

index 80eb445..035e94a 100644 (file)
@@ -54,10 +54,15 @@ require_once( 'WikiError.php' );
 function wfQuotedPrintable_name_and_emailaddr( $string ) {
 
        /* do not quote printable for email address string <emailaddr>, 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 );
+       }
 }
 
 /**