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

Questions containing scripts can't be exported in moodle-xml format

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5, 2.7.3, 2.8.1
    • Fix Version/s: 2.7.4, 2.8.2
    • Component/s: Questions
    • Labels:

      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> )

        Attachments

          Activity

            People

            Assignee:
            timhunt Tim Hunt
            Reporter:
            trampgeek Richard Lobb
            Peer reviewer:
            Jean-Michel Vedrine
            Integrator:
            Andrew Nicols
            Tester:
            Mark Nelson
            Participants:
            Component watchers:
            Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Fix Release Date:
              12/Jan/15