diff --git a/public/main/inc/lib/api.lib.php b/public/main/inc/lib/api.lib.php index d504d6e5bb..f21bbf486b 100644 --- a/public/main/inc/lib/api.lib.php +++ b/public/main/inc/lib/api.lib.php @@ -294,7 +294,7 @@ define('LOG_SURVEY_ID', 'survey_id'); define('LOG_SURVEY_CREATED', 'survey_created'); define('LOG_SURVEY_DELETED', 'survey_deleted'); define('LOG_SURVEY_CLEAN_RESULTS', 'survey_clean_results'); -define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.\$-]/'); +define('USERNAME_PURIFIER', '/[^0-9A-Za-z_\.@\$-]/'); //used when login_is_email setting is true define('USERNAME_PURIFIER_MAIL', '/[^0-9A-Za-z_\.@]/'); diff --git a/public/main/inc/lib/usermanager.lib.php b/public/main/inc/lib/usermanager.lib.php index 7cf7ae812f..07ccc8e396 100644 --- a/public/main/inc/lib/usermanager.lib.php +++ b/public/main/inc/lib/usermanager.lib.php @@ -1387,6 +1387,9 @@ class UserManager $return = 'true' === api_get_setting('login_is_email') ? substr(preg_replace(USERNAME_PURIFIER_MAIL, '', $username), 0, User::USERNAME_MAX_LENGTH) : substr(preg_replace(USERNAME_PURIFIER, '', $username), 0, User::USERNAME_MAX_LENGTH); $return = URLify::transliterate($return); + // We want everything transliterate() does except converting @ to '(at)'. This is a hack to avoid this. + $return = str_replace(' (at) ', '@', $return); + return $return; }