Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
bug #444 Incorrect character encoding due to transposed arguments for…
Browse files Browse the repository at this point in the history
… mbstring_convert_encoding (mbunzel)

This PR was merged into the 5.1-dev branch.

Discussion
----------

Incorrect character encoding due to transposed arguments for mbstring_convert_encoding

Depending on which extension is installed, swiftmailer will call mb_convert_encoding($string, $charset, 'utf-8') or iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string).

The signatures of these functions are mb_convert_encoding($str, $to_encoding, $from_encoding) and iconv($in_charset, $out_charset, string $str).

-> those two function calls do the exact opposite of each other. Users with installed mbstring extension will experience garbled output if the specified charset is any value other than utf-8 or iso-8850-1, in which case the conversion is skipped.

This pull request fixes the transposed arguments so that both mbstring and iconv will convert *from* $charset *to* utf-8.

Commits
-------

62a4be0 fixes transposed from-charset and to-charset arguments in mbstring_convert_encodng
  • Loading branch information
fabpot committed Mar 24, 2014
2 parents 306fa05 + 62a4be0 commit 82ec0cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/classes/Swift/Mime/MimePart.php
Expand Up @@ -203,7 +203,7 @@ protected function _convertString($string)
if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) {
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
if (function_exists('mb_convert_encoding')) {
$string = mb_convert_encoding($string, $charset, 'utf-8');
$string = mb_convert_encoding($string, 'utf-8', $charset);
} elseif (function_exists('iconv')) {
$string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string);
} else {
Expand Down

0 comments on commit 82ec0cd

Please sign in to comment.