Skip to content

Commit 82ec0cd

Browse files
committed
bug swiftmailer#444 Incorrect character encoding due to transposed arguments for 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
2 parents 306fa05 + 62a4be0 commit 82ec0cd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/classes/Swift/Mime/MimePart.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected function _convertString($string)
203203
if (!in_array($charset, array('utf-8', 'iso-8859-1', ''))) {
204204
// mb_convert_encoding must be the first one to check, since iconv cannot convert some words.
205205
if (function_exists('mb_convert_encoding')) {
206-
$string = mb_convert_encoding($string, $charset, 'utf-8');
206+
$string = mb_convert_encoding($string, 'utf-8', $charset);
207207
} elseif (function_exists('iconv')) {
208208
$string = iconv($charset, 'utf-8//TRANSLIT//IGNORE', $string);
209209
} else {

0 commit comments

Comments
 (0)