X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fmail%2FMailAddress.php;h=1a5d08ac2a2c5e3f205e6138a5e44f3a0879becf;hb=91ec64c80719f002426ada7aa1ed62b465c66a0a;hp=000bbe316bba5d5e1fa108feaf5207ddce230cff;hpb=50f6b24ee614196aae44dd67599f4c36ac6ade0d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/mail/MailAddress.php b/includes/mail/MailAddress.php index 000bbe316b..1a5d08ac2a 100644 --- a/includes/mail/MailAddress.php +++ b/includes/mail/MailAddress.php @@ -50,7 +50,7 @@ class MailAddress { * @param string|null $name Human-readable name if a string address is given * @param string|null $realName Human-readable real name if a string address is given */ - function __construct( $address, $name = null, $realName = null ) { + public function __construct( $address, $name = null, $realName = null ) { $this->address = strval( $address ); $this->name = strval( $name ); $this->realName = strval( $realName ); @@ -71,29 +71,30 @@ class MailAddress { * Return formatted and quoted address to insert into SMTP headers * @return string */ - function toString() { + public function toString() { + if ( !$this->address ) { + return ''; + } + # PHP's mail() implementation under Windows is somewhat shite, and # can't handle "Joe Bloggs " format email addresses, # so don't bother generating them - if ( $this->address ) { - if ( $this->name != '' && !wfIsWindows() ) { - global $wgEnotifUseRealName; - $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name; - $quoted = UserMailer::quotedPrintable( $name ); - // Must only be quoted if string does not use =? encoding (T191931) - if ( $quoted === $name ) { - $quoted = '"' . addslashes( $quoted ) . '"'; - } - return "$quoted <{$this->address}>"; - } else { - return $this->address; - } - } else { - return ""; + if ( $this->name === '' || wfIsWindows() ) { + return $this->address; } + + global $wgEnotifUseRealName; + $name = ( $wgEnotifUseRealName && $this->realName !== '' ) ? $this->realName : $this->name; + $quoted = UserMailer::quotedPrintable( $name ); + // Must only be quoted if string does not use =? encoding (T191931) + if ( $quoted === $name ) { + $quoted = '"' . addslashes( $quoted ) . '"'; + } + + return "$quoted <{$this->address}>"; } - function __toString() { + public function __toString() { return $this->toString(); } }