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

Moodle course search HTML entities not decoded

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Waiting for peer review
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.7
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide

      Actual result

      1. Log in to your Moodle site
      2. Edit a course and add an HTML entity like & in to the course fullname.
      3. Go to the course search (/course/search.php) and type in the search criteria (Type in an ampersand "&"!).
      4. Look at the search result and consider the error.

      Expected result

      1. Do the steps 1-3 like above.
      2. This time the ampersand will be decoded correct and not display as:

        &
        

       

      Reproduced on https://demo.moodle.net

      Show
      Actual result Log in to your Moodle site Edit a course and add an HTML entity like & in to the course fullname. Go to the course search (/course/search.php) and type in the search criteria (Type in an ampersand "&"!). Look at the search result and consider the error. Expected result Do the steps 1-3 like above. This time the ampersand will be decoded correct and not display as: &   Reproduced on  https://demo.moodle.net
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE
    • Pull from Repository:
    • Pull 3.6 Branch:
      wip-36-MDL-65355
    • Pull Master Branch:
      wip-master-MDL-65355

      Description

      The problem is that format_string per default escapes HTML entities. In this case the & will be encoded to:

      &
      

      To fix this issue we must decode HTML entities back to characters.

      There are two ways to go:

      1. Set in format_string options escape to false (https://docs.moodle.org/dev/Output_functions)
      2. Use the html_entity_decode function

        Attachments

        1. demo.moodle.net_error.png
          17 kB
          Adrian Perez
        2. searching for amp.png
          40 kB
          Eloy Lafuente (stronk7)

          Activity

            People

            • Assignee:
              pead Adrian Perez
              Reporter:
              pead Adrian Perez
              Participants:
              Component watchers:
              Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: