[Isocial-svn] SF.net SVN: isocial: [27] app/application_controller.php
Status: Pre-Alpha
Brought to you by:
aguidrevitch
From: <agu...@us...> - 2008-02-25 18:13:12
|
Revision: 27 http://isocial.svn.sourceforge.net/isocial/?rev=27&view=rev Author: aguidrevitch Date: 2008-02-25 10:13:14 -0800 (Mon, 25 Feb 2008) Log Message: ----------- 'from' and 'subject' email fields are correctly encoded as utf8 Modified Paths: -------------- app/application_controller.php Modified: app/application_controller.php =================================================================== --- app/application_controller.php 2008-02-25 18:10:24 UTC (rev 26) +++ app/application_controller.php 2008-02-25 18:13:14 UTC (rev 27) @@ -97,12 +97,9 @@ function sendHTMLemail( $to, $html, $enable_text = false) { list($header, $html) = preg_split('/\r?\n\r?\n/m', $html, 2); $headers = $this->extractHeaders( $header ); - - if (preg_match('/(\"[^\"]+\")/', $headers['From'], $matches)) { - $name = "=?utf-8?B?" . base64_encode($matches[0]) . "?="; - $headers['From'] = preg_replace('/\"[^\"]+\"/', $name, $headers['From']); - } + $headers['From'] = $this->_fix_email($headers['From']); + $body = "From: " . $headers['From'] . "\n"; $body .= "MIME-Version: 1.0\n"; $boundary = uniqid("HTMLEMAIL"); @@ -123,8 +120,8 @@ "Content-Type: text/html; charset=utf-8\n". "Content-Transfer-Encoding: base64\n\n"; $body .= chunk_split(base64_encode($html)); - - mail($to, $headers['Subject'], "", $body); + + mail($to, $this->_to_base64_utf8($headers['Subject']), "", $body); } function extractHeaders ( $header ) { @@ -150,7 +147,19 @@ { return $this->renderPartial("pageheader"); } + + function _fix_email ($value) { + // eats last space !!! + if (preg_match('/(.*?)\s+(<?\S+@\S+>?)/', $value, $matches)) { + $name = $this->_to_base64_utf8($matches[1]); + $value = $name . " " . $matches[2]; + } + return $value; + } + function _to_base64_utf8 ($value) { + return "=?utf-8?B?" . base64_encode($value) . "?="; + } } ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |