From 83345af059da5a73d14d04518e130bcb714ebc9c Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 22 Sep 2015 07:11:30 -0400
Subject: [PATCH] Log charset conversion warning only when no function was found, not when the string was invalid
---
program/lib/Roundcube/rcube_charset.php | 30 ++++++++++++++----------------
1 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/program/lib/Roundcube/rcube_charset.php b/program/lib/Roundcube/rcube_charset.php
index 3e6e614..beb2134 100644
--- a/program/lib/Roundcube/rcube_charset.php
+++ b/program/lib/Roundcube/rcube_charset.php
@@ -207,14 +207,14 @@
// it means that input string has been truncated
set_error_handler(array('rcube_charset', 'error_handler'), E_NOTICE);
try {
- $_iconv = iconv($from, $to . $iconv_options, $str);
+ $out = iconv($from, $to . $iconv_options, $str);
} catch (ErrorException $e) {
- $_iconv = false;
+ $out = false;
}
restore_error_handler();
- if ($_iconv !== false) {
- return $_iconv;
+ if ($out !== false) {
+ return $out;
}
}
@@ -258,20 +258,17 @@
// convert charset using bundled classes/functions
if ($to == 'UTF-8') {
if ($from == 'UTF7-IMAP') {
- if ($_str = self::utf7imap_to_utf8($str)) {
- return $_str;
+ if ($out = self::utf7imap_to_utf8($str)) {
+ return $out;
}
}
else if ($from == 'UTF-7') {
- if ($_str = self::utf7_to_utf8($str)) {
- return $_str;
+ if ($out = self::utf7_to_utf8($str)) {
+ return $out;
}
}
else if ($from == 'ISO-8859-1' && function_exists('utf8_encode')) {
return utf8_encode($str);
- }
- else {
- trigger_error("No suitable function found for UTF-8 encoding");
}
}
@@ -279,16 +276,17 @@
if ($from == 'UTF-8') {
// @TODO: we need a function for UTF-7 (RFC2152) conversion
if ($to == 'UTF7-IMAP' || $to == 'UTF-7') {
- if ($_str = self::utf8_to_utf7imap($str)) {
- return $_str;
+ if ($out = self::utf8_to_utf7imap($str)) {
+ return $out;
}
}
else if ($to == 'ISO-8859-1' && function_exists('utf8_decode')) {
return utf8_decode($str);
}
- else {
- trigger_error("No suitable function found for UTF-8 decoding");
- }
+ }
+
+ if (!isset($out)) {
+ trigger_error("No suitable function found for '$from' to '$to' conversion");
}
// return original string
--
Gitblit v1.9.1