Skip to content

Commit

Permalink
Removed mb_* function checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Sep 28, 2012
1 parent 32a066c commit e7af1be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 24 deletions.
13 changes: 4 additions & 9 deletions lib/Cake/Network/Email/Email.php
Expand Up @@ -1203,18 +1203,13 @@ public function reset() {
* @return string Encoded string
*/
protected function _encode($text) {
$internalEncoding = function_exists('mb_internal_encoding');
if ($internalEncoding) {
$restore = mb_internal_encoding();
mb_internal_encoding($this->_appCharset);
}
$restore = mb_internal_encoding();
mb_internal_encoding($this->_appCharset);
if (empty($this->headerCharset)) {
$this->headerCharset = $this->charset;
}
$return = mb_encode_mimeheader($text, $this->headerCharset, 'B');
if ($internalEncoding) {
mb_internal_encoding($restore);
}
mb_internal_encoding($restore);
return $return;
}

Expand All @@ -1227,7 +1222,7 @@ protected function _encode($text) {
* @return string
*/
protected function _encodeString($text, $charset) {
if ($this->_appCharset === $charset || !function_exists('mb_convert_encoding')) {
if ($this->_appCharset === $charset) {
return $text;
}
return mb_convert_encoding($text, $charset, $this->_appCharset);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Response.php
Expand Up @@ -477,7 +477,7 @@ protected function _setContentLength() {
}
if ($shouldSetLength && !$this->outputCompressed()) {
$offset = ob_get_level() ? ob_get_length() : 0;
if (ini_get('mbstring.func_overload') & 2 && function_exists('mb_strlen')) {
if (ini_get('mbstring.func_overload') & 2) {
$this->length($offset + mb_strlen($this->_body, '8bit'));
} else {
$this->length($this->_headers['Content-Length'] = $offset + strlen($this->_body));
Expand Down
14 changes: 0 additions & 14 deletions lib/Cake/Test/TestCase/Network/Email/EmailTest.php
Expand Up @@ -302,8 +302,6 @@ public function testFormatAddress() {
* @return void
*/
public function testFormatAddressJapanese() {
$this->skipIf(!function_exists('mb_convert_encoding'));

$this->CakeEmail->headerCharset = 'ISO-2022-JP';
$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '日本語Test'));
$expected = array('=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCVGVzdA==?= <cake@cakephp.org>');
Expand Down Expand Up @@ -445,7 +443,6 @@ public function testSubject() {
* @return void
*/
public function testSubjectJapanese() {
$this->skipIf(!function_exists('mb_convert_encoding'));
mb_internal_encoding('UTF-8');

$this->CakeEmail->headerCharset = 'ISO-2022-JP';
Expand Down Expand Up @@ -1048,8 +1045,6 @@ public function testSendRender() {
* @return void
*/
public function testSendRenderJapanese() {
$this->skipIf(!function_exists('mb_convert_encoding'));

$this->CakeEmail->reset();
$this->CakeEmail->transport('debug');

Expand Down Expand Up @@ -1115,7 +1110,6 @@ public function testSendRenderWithVars() {
* @return void
*/
public function testSendRenderWithVarsJapanese() {
$this->skipIf(!function_exists('mb_convert_encoding'));
$this->CakeEmail->reset();
$this->CakeEmail->transport('debug');

Expand Down Expand Up @@ -1601,7 +1595,6 @@ public function testConfigCharset() {
* @return void
*/
public function testHeaderEncoding() {
$this->skipIf(!function_exists('mb_convert_encoding'));
$email = new Email(array('headerCharset' => 'iso-2022-jp-ms', 'transport' => 'Debug'));
$email->subject('あれ?もしかしての前と');
$headers = $email->getHeaders(array('subject'));
Expand All @@ -1619,7 +1612,6 @@ public function testHeaderEncoding() {
* @return void
*/
public function testBodyEncoding() {
$this->skipIf(!function_exists('mb_convert_encoding'));
$email = new Email(array(
'charset' => 'iso-2022-jp',
'headerCharset' => 'iso-2022-jp-ms',
Expand All @@ -1642,7 +1634,6 @@ public function testBodyEncoding() {
* @return void
*/
public function testBodyEncodingIso2022Jp() {
$this->skipIf(!function_exists('mb_convert_encoding'));
$email = new Email(array(
'charset' => 'iso-2022-jp',
'headerCharset' => 'iso-2022-jp',
Expand All @@ -1666,7 +1657,6 @@ public function testBodyEncodingIso2022Jp() {
* @return void
*/
public function testBodyEncodingIso2022JpMs() {
$this->skipIf(!function_exists('mb_convert_encoding'));
$email = new Email(array(
'charset' => 'iso-2022-jp-ms',
'headerCharset' => 'iso-2022-jp-ms',
Expand Down Expand Up @@ -1717,8 +1707,6 @@ protected function _checkContentTransferEncoding($message, $charset) {
* @return void
*/
public function testEncode() {
$this->skipIf(!function_exists('mb_convert_encoding'));

$this->CakeEmail->headerCharset = 'ISO-2022-JP';
$result = $this->CakeEmail->encode('日本語');
$expected = '=?ISO-2022-JP?B?GyRCRnxLXDhsGyhC?=';
Expand Down Expand Up @@ -1770,8 +1758,6 @@ public function testHeaderCharset() {
* headerCharset property and headerCharset() method.
*/
public function testCharsetsCompatible() {
$this->skipIf(!function_exists('mb_convert_encoding'));

$checkHeaders = array(
'from' => true,
'to' => true,
Expand Down

0 comments on commit e7af1be

Please sign in to comment.