← Back to team overview

mahara-contributors team mailing list archive

[Bug 1026618] Re: The registration link can fail if a user's name contains a diacritic

 

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.

-- 
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
https://bugs.launchpad.net/bugs/1026618

Title:
  The registration link can fail if a user's name contains a diacritic

Status in Mahara ePortfolio:
  New

Bug description:
  Please note this only seems to effect PHP running on Windows, not
  Ubuntu.

  In the following configuration:
  Windows Server 2008 R2
  IIS 7
  Postgresql 9.1.4
  PHP 5.3.13
  Mahara 1.5.1

  The registration link ("Hi Chéese, Thank you for registering an
  account on Mahara. Please follow this link to complete the signup
  process: ...") won't work if the user has a diacritic in their name.

  Clicking the link results in "A nonrecoverable error occured. This
  probably means you have encountered a bug in the system"

  The email address confirmation message ("Hi Chéese, Thank you for
  registering an account on Mahara. Please select the following link to
  confirm your email address. The ...") and the message sent to the
  administrator to approve the registration work perfectly.

  Attached is a relevant snippet from the PHP error log.

To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1026618/+subscriptions


References