Moodle
  1. Moodle
  2. MDL-22100

Backslashes in category names need to be escaped in MoodleXML export

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9.8
    • Fix Version/s: 1.9.10
    • Component/s: Questions
    • Labels:
      None
    • Database:
      Any
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_19_STABLE
    • Rank:
      26843

      Description

      Question bank categories with backslashes in their name cause problems when exported in MoodleXML format. The backslashes are not escaped, and thus when the XML file is imported into another course the slashes are interpreted as path delimiters, nesting later parts of the title within earlier parts.

      example: a category called "terms/concepts of psycho/neurolinguistics (T/F questions)" would get imported as four nested categories:
      -terms
      --concepts of psycho
      ---neurolinguistics (T
      ----F questions)

        Issue Links

          Activity

          Hide
          Howard Miller added a comment -

          I've known about this for ages and I have a vague recollection that it was really difficult to fix. I'll need to have a think

          Show
          Howard Miller added a comment - I've known about this for ages and I have a vague recollection that it was really difficult to fix. I'll need to have a think
          Hide
          Tim Hunt added a comment -

          People are complaining about this at the OU, so I am going to fix it.

          The problem is caused by the call to clean_param($catpath, PARAM_PATH) in the create_category_path method, and ' characters also cause problems.

          Show
          Tim Hunt added a comment - People are complaining about this at the OU, so I am going to fix it. The problem is caused by the call to clean_param($catpath, PARAM_PATH) in the create_category_path method, and ' characters also cause problems.
          Hide
          Tim Hunt added a comment -

          OK, and the converse function that constructs the path that is written to the file from the data in the database is get_category_path. So the real problem is to ensure that get_category_path and create_category_path are exact opposites.

          And, when creating a category through the Moodle UI, the type for category names is PARAM_MULTILANG.

          Show
          Tim Hunt added a comment - OK, and the converse function that constructs the path that is written to the file from the data in the database is get_category_path. So the real problem is to ensure that get_category_path and create_category_path are exact opposites. And, when creating a category through the Moodle UI, the type for category names is PARAM_MULTILANG.
          Hide
          Tim Hunt added a comment -

          Should be fixed now.

          I wrote some pleasingly evil unit tests for the logic that combines the separate names into a path, and splits is back into separate names. I think I covered all bases.

          I think the new code is as backwards-compatible as it is possible to be.

          Show
          Tim Hunt added a comment - Should be fixed now. I wrote some pleasingly evil unit tests for the logic that combines the separate names into a path, and splits is back into separate names. I think I covered all bases. I think the new code is as backwards-compatible as it is possible to be.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: