Moodle

& signs in CDATA sections are imported as &

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor 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?

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: