Usernames get wrong encoding (Lithuanian language)

18 years 4 months ago #876 by elesus
Hello,

when I upgraded CB RC1 to RC2 I have a problem in some parts of CB which displays usernames (and real names). The language specific letters get encoded in html special characters.

These parts are connections "incons", user profiles coneection-path and may be more?

I do not use UTF-8 on my site. My charset is "windows-1257".

The problem as I see it is in the htmlentities function which converts all the symbols to special html symbols. This function does not support "cp1257" (windows-1257) so it assumes the charset is "ISO-8859-1", then all the Lithuanian specific symbols get changed to html codes.

To fix it I replaced htmlentities to htmlspecialchars in some places, but there are a lot of places where htmlentities is used.

One more linked problem is in the Forum tab. When I try to sort posts by subject, category or hits i get the error:
[code:1]Warning: html_entity_decode(): charset `windows-1257' not supported, assuming iso-8859-1 in /root/www/administrator/components/com_comprofiler/comprofiler.class.php on line 1427[/code:1]

How to solve these problems?

Post edited by: elesus, at: 2005/11/29 10:00

СB3РD

Please Log in to join the conversation.

18 years 4 months ago #946 by beat
You are very right. Thanks for the heads-up. Also noticed this annoying charsets bug and their origin. I'm on my way to fixing these, but have a lack of free time these days, so please post or PM me if you have some advance. Yes, most of these were introduced all over in RC2 to fix some other RC1 bugs... :whistle:

Sorry about that. :blush:

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in to join the conversation.

18 years 4 months ago #948 by feddyups
As in the previous thread, Greek and CB, i believe this is the exact same bug elesus is talking about here.
With the help of Beat, I've got so far:

The problem for the name is in components/com_comprofiler/plugin/user/plug_cbcore/cb.core.php in method getEditTab()


If you remove the htmlentities in that method it will work for name, but will not protect anymore from malicious names....

If you have found a good workaround for removing or replacing the aforementioned antities, please post it here for all of us to work with and evolve, until the issue is properly resolved.

Please Log in to join the conversation.

18 years 4 months ago #968 by elesus
Most of the wrong encoding had gone when I replaced all the occurencies of htmlentities with htmlspecialchars in the components/com_comprofiler/plugin/user/plug_cbcore/cb.core.php and components/com_comprofiler/plugin/user/plug_cbcore/cb.connections.php

СB3РD

Please Log in to join the conversation.

18 years 4 months ago #969 by elesus
The solution for the sorting problem which I had in the SimpleBoard tab is shown below:

[code:1]
function unhtmlentities ($string, $quotes, $charset) {
if ((phpversion() < '5.0.0') && ((phpversion() < '4.3.0') || !((strncmp($charset,"ISO-8859",8)==0) || ereg("1251",$charset) || ereg("1252",$charset)))) {
// For 4.1.0 =< PHP < 4.3.0 use this function instead of html_entity_decode: also php < 5.0 does not support UTF-8 outputs !
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
} else {
return html_entity_decode ($string, $quotes, $charset);
}
}
[/code:1]

The charset I use is cp1257 but it is not supported by the html_entity_decode function, so I changed the check to ereg("1251",$charset) || ereg("1252",$charset) instead of ereg("125",$charset)

Post edited by: elesus, at: 2005/11/30 12:28

СB3РD

Please Log in to join the conversation.

18 years 4 months ago #971 by elesus
On more place (I hope it is the last one) that caused me trouble is in the /components/com_comprofiler/comprofiler.php on line 1357 in the addConnection method.

All the info messages (alerts) are not passed through the addslashes and htmlentities functions, except the mentioned above line. So I just made a substitute:

.addslashes(htmlentities($cbCon->getUserMSG())).

changed with:

.$cbCon->getUserMSG().

Right now I do not see any charset problems on my site. May be I will discover more later. I will definetely write in this thread if I do.

СB3РD

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.204 seconds

Facebook Twitter LinkedIn