From: Tim Starling Date: Sat, 14 Oct 2006 05:38:31 +0000 (+0000) Subject: Fixed line endings on Windows. Cleaned up PHP 5 error messages. X-Git-Tag: 1.31.0-rc.0~55499 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=8a61d5fc2e2430f5556c7f9df765b8e6cd354eca;p=lhc%2Fweb%2Fwiklou.git Fixed line endings on Windows. Cleaned up PHP 5 error messages. --- diff --git a/includes/UserMailer.php b/includes/UserMailer.php index 78a8be91ef..9428761038 100644 --- a/includes/UserMailer.php +++ b/includes/UserMailer.php @@ -125,14 +125,23 @@ function userMailer( $to, $from, $subject, $body, $replyto=false ) { } else { # In the following $headers = expression we removed "Reply-To: {$from}\r\n" , because it is treated differently # (fifth parameter of the PHP mail function, see some lines below) + + # Line endings need to be different on Unix and Windows due to + # the bug described at http://trac.wordpress.org/ticket/2603 + if ( wfIsWindows() ) { + $body = str_replace( "\n", "\r\n", $body ); + $endl = "\r\n"; + } else { + $endl = "\n"; + } $headers = - "MIME-Version: 1.0\n" . - "Content-type: text/plain; charset={$wgOutputEncoding}\n" . - "Content-Transfer-Encoding: 8bit\n" . - "X-Mailer: MediaWiki mailer\n". - 'From: ' . $from->toString() . "\n"; + "MIME-Version: 1.0$endl" . + "Content-type: text/plain; charset={$wgOutputEncoding}$endl" . + "Content-Transfer-Encoding: 8bit$endl" . + "X-Mailer: MediaWiki mailer$endl". + 'From: ' . $from->toString(); if ($replyto) { - $headers .= "Reply-To: $replyto\n"; + $headers .= "{$endl}Reply-To: $replyto"; } $dest = $to->toString(); @@ -158,7 +167,7 @@ function userMailer( $to, $from, $subject, $body, $replyto=false ) { */ function mailErrorHandler( $code, $string ) { global $wgErrorString; - $wgErrorString = preg_replace( "/^mail\(\): /", '', $string ); + $wgErrorString = preg_replace( '/^mail\(\)(\s*\[.*?\])?: /', '', $string ); }