Distorted cyrillic logins [message #160753] |
Wed, 21 October 2009 14:59 |
gorm
Messages: 29 Registered: October 2009 Location: Moscow, Russia
Karma: 0
|
Junior Member |
|
|
After looking through many different forums I chose FUDforum. I installed FUDforum 3.0.0 RC2 and it works except that it is not possible to register users with Cyrillic logins. They become distorted after registration or even immediately in the form in case of unsuccessful registration.
I use Ubuntu 9.04 with apache, locale is ru_RU.utf8, the forum is configured for SQLite and ru_RU.utf8 is set in the theme manager.
|
|
|
|
|
Re: Distorted cyrillic logins [message #160771 is a reply to message #160755] |
Thu, 22 October 2009 17:23 |
|
naudefj
Messages: 3775 Registered: December 2004
Karma: 28
|
Senior Member Administrator Core Developer |
|
|
Here is a patch for you to evaluate and test:
RCS file: /forum21/install/forum_data/src/register.php.t,v
retrieving revision 1.181
diff -u -a -r1.181 register.php.t
--- install/forum_data/src/register.php.t 15 Sep 2009 18:11:29 -0000 1.181
+++ install/forum_data/src/register.php.t 22 Oct 2009 17:09:58 -0000
@@ -55,15 +55,14 @@
function sanitize_login($login)
{
- $list = '&'.chr(173);
+ // Remove control, formatting, and surrogate characters.
+ $login = preg_replace( '/[\p{Cc}\p{Cf}\p{Cs}]/u', ' ', $login);
- for ($i = 0; $i < 32; $i++) {
- $list .= chr($i);
- }
- for ($i = 127; $i < 161; $i++) {
- $list .= chr($i);
- }
- return strtr($login, $list, str_repeat(" ", strlen($list)));
+ // Other "bad" characters to remove.
+ $badchars = '&';
+ for ($i = 0; $i < 32; $i++) $badchars .= chr($i);
+
+ return strtr($login, $badchars, str_repeat(' ', strlen($badchars)));
}
function register_form_check($user_id)
|
|
|
|
|
|
|
|
|
|