Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions program/lib/Roundcube/rcube_mime.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,29 @@ public static function decode_mime_string($input, $fallback = null)
// add the last part of the input string
if ($start != strlen($input)) {
$input = substr($input, $start);
$out .= $fallback === false ? $input : rcube_charset::convert($input, $default_charset);
if ($fallback === false) {
$out .= $input;
} elseif (mb_check_encoding($input, 'UTF-8') && preg_match('/[\x80-\xFF]/', $input)) {
// Valid UTF-8 with high bytes - don't corrupt with wrong charset conversion
$out .= $input;
} else {
$out .= rcube_charset::convert($input, $default_charset);
}
}

// return the results
return $out;
}

// no encoding information, use fallback
return $fallback === false ? $input : rcube_charset::convert($input, $default_charset);
if ($fallback === false) {
return $input;
}
// Valid UTF-8 with high bytes - don't corrupt with wrong charset conversion
if (mb_check_encoding($input, 'UTF-8') && preg_match('/[\x80-\xFF]/', $input)) {
return $input;
}
return rcube_charset::convert($input, $default_charset);
}

/**
Expand Down