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

& signs in CDATA sections are imported as &

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9
    • 1.8.7, 1.9.3, 2.0
    • SCORM
    • None
    • MOODLE_19_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE, MOODLE_20_STABLE

    Description

      When the imsmanifest.xml contains & sign in CDATA section (e.g. prerequisites with & operator), it will be imported as & into the database.
      It is occurred because all occurrences of single '&' signs are replaced with '&' in the scormlib.php (line 467) before xml parsing:

      $pattern = '/&(?!\w

      {2,6}

      /';
      $replacement = '&';
      $xmltext = preg_replace($pattern, $replacement, $xmltext);

      It is problem when the & sign is in CDATA section.

      The possible solution is to remove the 3 lines above. I tested the SCORM import with the following situations (removed 3 lines above):

      • The '&' sign was escaped as '&' in the XML: Text was successfully imported, single '&' sign was written into the database.
      • The '&' sign was in CDATA section: Texts was successfully imported, single '&' sign was written into the database.
      • Single '&' sign in the XML (without escape or CDATA): XML error thrown (XML error: XML_ERR_NAME_REQUIRED). It is correct, because & signs must be escaped (or be in CDATA section) in XML.

      So, if there is no another situation, I thought, the 3 lines can be removed. Is there other known situation?

      Attachments

        Activity

          People

            piers Piers Harding
            szazo Zoltán Szarvas
            Dan Marsden, Matteo Scaramuccia, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              15/Oct/08