Details
Description
During the use of Moodle at the Florence University (Computer Science Degree),
we meet the following problem:
the locked fields of user profile are not leaked for deleting MySql special characters: i.e., when a user changes his profile, locked fields are copied without applying the function addslashes. If one of such fields contains, for example, ' (apostrophe) or any other MySql special character, Moodle (version 1.5.x) gives an error message when tries to save data on the database. The file moodle/user/edit.php has to be edited to solve this problem as follow:
Original code :
// override locked values
if (!isadmin()) {
$fields = get_user_fieldnames();
$authconfig = get_config( 'auth/' . $user->auth );
foreach ($fields as $field) {
$configvariable = 'field_lock_' . $field;
if ( $authconfig->{$configvariable} === 'locked'
// ($authconfig->{
$configvariable} === 'unlockedifempty'
&& !empty($user->$field)) )
{if (!empty( $user->$field)) {
// Original string
$usernew->$field = $user->$field;}
}
}
Modified Code:
// override locked values
if (!isadmin()) {
$fields = get_user_fieldnames();
$authconfig = get_config( 'auth/' . $user->auth );
foreach ($fields as $field) {
$configvariable = 'field_lock_' . $field;
if ( $authconfig->{$configvariable} === 'locked'
// ($authconfig->{
$configvariable}} === 'unlockedifempty'
&& !empty($user->$field)) )
{if (!empty( $user->$field)) { // Modified String $usernew->$field = addslashes(clean_text(stripslashes(trim ($user->$field)), FORMAT_MOODLE)); }
}
Issue Links
| This issue has a clone: | ||||
| MDL-6613 | Apostrophe in surname prevents user updating profile |
|
|
|
From Roger Spurgeon (toprow at gmail.com) Wednesday, 14 December 2005, 12:38 AM:
See also
MDL-4073.MDL-4073.