Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-54967

IMS Common Cartridge import incorrectly decodes html entities in URLs

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Testing instructions:

      1. Create / use a Moodle Course using Moodle 3.3 / 3.4 / latest stable master
      2. Download example IMS CC backup ("ims-common-cartridge-test-export.imscc") attached to this ticket
      3. Click on the Moodle Course's "Restore Course" functionality
      4. Drag and drop the IMS CC backup to the "Import a backup file" area
      5. Click Continue on the Backup details summary page
      6. Click Restore into this course, and select "Delete the contents of this course and then restore"
      7. You should be able to continue with the rest of the restoration workflow successfully
      8. You should not encounter an error like the following screenshot:
      Show
      Testing instructions: Create / use a Moodle Course using Moodle 3.3 / 3.4 / latest stable master Download example IMS CC backup ("ims-common-cartridge-test-export.imscc") attached to this ticket Click on the Moodle Course's "Restore Course" functionality Drag and drop the IMS CC backup to the "Import a backup file" area Click Continue on the Backup details summary page Click Restore into this course, and select "Delete the contents of this course and then restore" You should be able to continue with the rest of the restoration workflow successfully You should not encounter an error like the following screenshot:
    • Affected Branches:
      MOODLE_27_STABLE, MOODLE_31_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Pull 3.3 Branch:
    • Pull 3.4 Branch:
    • Pull Master Branch:
      MDL-54967-master

      Description

      I have an IMS Common Cartridge course backup from Canvas. I have validated it here:

      http://validator.imsglobal.org/cc/index.jsp?validate=cartridge

      When I try to restore it to Moodle, the import fails with the following error message:

      error/

      Fatal Error in [tempdir]/backup/5d39251534af9adb46e401f27f517662/moodle.xml: EntityRef: expecting ';' at line 221

      When Moodle creates "moodle.xml", it is incorrectly decoding html entities in the URL. This makes the XML parser choke when it encounters an ampersand, because it expects this to be the start of an entity reference.

      The workaround is to change cc11_resource::create_node_course_modules_mod_resource() in backup/cc/entity11.resource.class.php as follows:

      diff --git a/backup/cc/entity11.resource.class.php b/backup/cc/entity11.resource.class.php
      index bc5bb5a..d383352 100644
      --- a/backup/cc/entity11.resource.class.php
      +++ b/backup/cc/entity11.resource.class.php
      @@ -99,7 +99,7 @@ class cc11_resource extends entities11 {
                                       $link = 'http://invalidurldetected/';
                                   }
                               } else {
      -                            $link = $rawlink;
      +                            $link = htmlentities($rawlink);
                               }
                           }
                       }
      

      (I am absolutely certain this is the wrong approach, by the way. It's only a workaround)

        Attachments

          Activity

            People

            • Votes:
              8 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                15/Jan/18