Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix strtolower calls incompatible with utf-8 #725

Open
wants to merge 1 commit into
base: MOODLE_39_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions classes/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ public function saml_login_complete($attributes) {
$accentsensitive = true;
if ($this->config->tolower == saml2_settings::OPTION_TOLOWER_LOWER_CASE) {
$this->log(__FUNCTION__ . " to lowercase for $uid");
$uid = strtolower($uid);
$uid = \core_text::strtolower($uid);
}
if ($this->config->tolower == saml2_settings::OPTION_TOLOWER_CASE_INSENSITIVE) {
$this->log(__FUNCTION__ . " case insensitive compare for $uid");
Expand Down Expand Up @@ -696,7 +696,7 @@ public function saml_login_complete($attributes) {
$this->update_user_record_from_attribute_map($user, $attributes, true);
if (empty($user->username)) {
// Just in case username field not set, use uid.
$user->username = strtolower($uid);
$user->username = \core_text::strtolower($uid);
}
// Set the auth to saml2 if it's not set from the attributes.
if (empty($user->auth)) {
Expand Down Expand Up @@ -979,7 +979,7 @@ public function update_user_record_from_attribute_map(&$user, $attributes, $newu
}
}
if ($field == 'username') {
$user->$field = strtolower($attributes[$attr][0]);
$user->$field = \core_text::strtolower($attributes[$attr][0]);
} else {
// Custom profile fields have the prefix profile_field_ and will be saved as profile field data.
$delimiter = $mapconfig->fielddelimiter;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ public function get_email_from_attributes(array $attributes) {
*/
private function get_username_from_attributes(array $attributes) {
if (!empty($this->config->field_map_username) && !empty($attributes[$this->config->field_map_username])) {
return strtolower($attributes[$this->config->field_map_username][0]);
return \core_text::strtolower($attributes[$this->config->field_map_username][0]);
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/behat/behat_auth_saml2.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function the_saml_setting_is_set_to_auth_saml($setting, $value) {
$setting = 'flagmessage';
}

$lowervalue = strtolower($value);
$lowervalue = core_text::strtolower($value);
$value = array_key_exists($lowervalue, $map) ? $map[$lowervalue] : $value;
set_config($setting, $value, 'auth_saml2');
}
Expand Down