Moodle
  1. Moodle
  2. MDL-21370

Special character escaping error while restoring user data from backup.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.7
    • Fix Version/s: 1.9.8
    • Component/s: Backup
    • Labels:
      None
    • Environment:
      postgresql, linux
    • Database:
      PostgreSQL
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      26539

      Description

      It seems like the restore_create_users function in backup/restorelib.php is escaping user data too many times. Which results in having extra '\' characters in user field.

      Reproduction:
      1. On one moodle instance create a test course and a test user with lastname being o'reilly. Then make this user a student of the course. Create a backup of this course and ask for course users to be exported.
      2. On another moodle instance restore this course with its users, make sure that this moodle instance doesn't have a user with the same username, so that it will actually create a new user.
      3. After that browse the moodle user list and search for your user. In the user details you will see that its lastname has become o\'reilly.

      The problem seems to happen on any user field. It seems that the function restore_create_users is calling addslashes twice to escape user information. Once at line 2812 when calling backup_todb function, and another time before inserting the new record at line 3015 when calling addslashes_recursive.

      I have attached a patch to this problem that fixes it.

        Activity

        Hide
        Eloy Lafuente (stronk7) added a comment -

        Well spotted, jean-christophe

        Reproduced, patch applied and tested. Seems to be working ok now.

        Thanks and ciao

        Show
        Eloy Lafuente (stronk7) added a comment - Well spotted, jean-christophe Reproduced, patch applied and tested. Seems to be working ok now. Thanks and ciao

          People

          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: