Comment 2 for bug 1026618

Revision history for this message
Simon Story (simon-story) wrote :

I see this is get_new_username() using substr in a non-utf8 safe way, I think I've fixed that. Something like:

index b90a9fc..72c0a83 100644
--- a/htdocs/lib/user.php
+++ b/htdocs/lib/user.php
@@ -1402,7 +1402,7 @@ function get_new_username($desired) {
     $taken = get_column_sql('
         SELECT LOWER(username) FROM {usr}
         WHERE username ' . db_ilike() . " ?",
- array(substr($desired, 0, $maxlen - 6) . '%'));
+ array(utf8_encode(substr(utf8_decode($desired), 0, $maxlen - 6) . '%')));
     if (!$taken) {
         return $desired;
     }

I think I've fixed that function, but then problem moves into create_user() :-/.

Wild speculation: I think the root of this problem is the Windows PHP binaries installed use plain libiconv 1.11 and on ubuntu php uses the bundled glibc iconv functions and things are behaving slightly differently.