Details
-
Type:
Bug
-
Status: Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.5, 2.7.3, 2.8.1
-
Component/s: Questions
-
Testing Instructions:
- Create a question containing some of the tricky content from the comments here.
- Export the category containing that question as Moodle XML, and re-import, and verify that it works.
-
Affected Branches:MOODLE_25_STABLE, MOODLE_27_STABLE, MOODLE_28_STABLE
-
Fixed Branches:MOODLE_27_STABLE, MOODLE_28_STABLE
-
Pull from Repository:
-
Pull Master Branch:
-
Pull Master Diff URL:
Description
If one uses HTML editing mode to insert a script into a question text (e.g. to show/hide a part of the question) and then attempts to export the question, a syntactically invalid XML file results. The reason is that the script gets automatically wrapped as CDATA[...], but the question exporter calls $format->xml_escape which also wraps the question in CDATA[...]. This fails, because CDATA sections cannot be nested.
Steps to reproduce:
1. Create a new question, e.g. a Description question.
2. Switch to HTML mode and insert as question text: <script>alert("try this")</script>
3. Update and save the question.
4. Preview the question: it brings up an alert
5. Export the question in Moodle XML format
6. Attempt to open the exported file: it gives an XML parsing Error (mismatched tag, expected </text> )