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

& signs in CDATA sections are imported as &

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 1.8.7, 1.9.3, 2.0
    • Component/s: SCORM
    • Labels:
      None
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      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

            Assignee:
            piers Piers Harding
            Reporter:
            szazo Zoltán Szarvas
            Participants:
            Component watchers:
            Damyon Wiese, Dan Marsden, Matteo Scaramuccia, Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              15/Oct/08