Patch to fix incorrect mbstring usage
|Reported by:||liels_bugs||Owned by:||roundcube|
First of all, thanks for the great product! Hopefully my patch will help to make it more suitable for non-english people too. * * * program/include/main.inc contains two errors in mbstring usage. These errors prevent mbstring from using on non-english languages and cause empty body for messages with non-english character sets (like koi8-r or windows-1257). Firsts, this file determines if mbstring can be used at all and it does it by calling mb_language. This is wrong because this function is not right for this task. Suppose your display language is Latvian (mb_language returns false for "lv"). You get e-mail with Norwegian letters and charset. Now you are going to convert it to utf-8 but you cannot do it because you just disabled mbstring! And you did it by checking the language code that has nothing to do with incoming mail or display encoding. These are completely unrelated things! Second, code incorrectly works with mb_convert_encoding. It tries to check if encoding is directly supported by comparing it to arrays. This will work in some cases but not in all. Your code depends on the existance of mb_string_encodings, which is not always present. Thus you leave many charsets out. In fact, most of them for all PHP4 versions. Instead you should call mb_convert_encoding and compare result to empty string (read manual!). This is the only right way. I attach the patch that fixes mb_string usage and makes proper conversion. I did not look to anything else in the file, just fixed mbstring issues. Patch is verified on my test server. You make a great product - fast, nice looking and very promising. Hope you will succeed. I started to play with it 2 hours ago and already became a big fan :) Very, very good!
Change History (4)
Note: See TracTickets for help on using tickets.