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

Moodle course search HTML entities not decoded

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 3.6, 3.6.1, 3.6.2, 3.6.3, 3.6.4, 3.7, 4.4.6, 4.5.2, 5.0
    • Course
    • MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE, MOODLE_500_STABLE
    • MDL-65355-404
    • MDL-65355-405
    • MDL-65355-main
    • Easy
    • Hide
      1. Login as a site admin
      2. Go to Preferences in the user menu
      3. Click on the Editor preferences link
      4. Ensure "Text editor" is set to "TinyMCE editor" or "Atto HTML editor"
      5. Create a new course
        1. Set "Course full name" to "Test & € search encoding"
        2. Set "Course summary" to "Test description & € search encoding"
      6. In the primary navigation go to Site administration
      7. Under the General tab, go to Site home > Site home settings
      8. For the "Site home items when logged in" setting, change one of the select options to "Course search box", then save
      9. In the primary navigation go to Home
      10. You should see a "Search courses" field on the page
      11. Search for "Test &"
      12. Ensure search results return a course with name "Test & € search encoding"
      13. Ensure in course name, "Test &" is highlighted
      14. Ensure in course summary, "Test" and "&" are highlighted.
      15. Ensure the course name is shown as

        Test & € search encoding


        and not

        Test & € search encoding

      16. Ensure the course summary is shown as

        Test description & € search encoding


        and not

        Test description & € search encoding

      17. Search for "€"
      18. Ensure in course name, "€" is highlighted
      19. Ensure in course summary, "€" is highlighted.
      20. Repeat steps 15 and 16
      21. Go to Preferences in the user menu
      22. Click on the Editor preferences link
      23. Change "Text editor" to "Plain text area"
      24. Edit the same course you created in step 2
      25. Update the Course summary to be the following

        Test description & € search encoding

      26. Repeat steps 9 to 20
      Show
      Login as a site admin Go to Preferences in the user menu Click on the Editor preferences link Ensure "Text editor" is set to "TinyMCE editor" or "Atto HTML editor" Create a new course Set "Course full name" to "Test & € search encoding" Set "Course summary" to "Test description & € search encoding" In the primary navigation go to Site administration Under the General tab, go to Site home > Site home settings For the "Site home items when logged in" setting, change one of the select options to "Course search box", then save In the primary navigation go to Home You should see a "Search courses" field on the page Search for "Test &" Ensure search results return a course with name "Test & € search encoding" Ensure in course name, "Test &" is highlighted Ensure in course summary, "Test" and "&" are highlighted. Ensure the course name is shown as Test & € search encoding and not Test & € search encoding Ensure the course summary is shown as Test description & € search encoding and not Test description & € search encoding Search for "€" Ensure in course name, "€" is highlighted Ensure in course summary, "€" is highlighted. Repeat steps 15 and 16 Go to Preferences in the user menu Click on the Editor preferences link Change "Text editor" to "Plain text area" Edit the same course you created in step 2 Update the Course summary to be the following Test description & € search encoding Repeat steps 9 to 20
    • Hide

      Code verified against automated checks.

      Checked MDL-65355 using repository: https://github.com/rhell4/moodle

      More information about this report

      Built on: Sun Dec 15 10:58:16 PM UTC 2024

      Show
      Code verified against automated checks. Checked MDL-65355 using repository: https://github.com/rhell4/moodle MOODLE_404_STABLE (0 errors / 0 warnings) [branch: MDL-65355-404 | CI Job ] MOODLE_405_STABLE (0 errors / 0 warnings) [branch: MDL-65355-405 | CI Job ] main (0 errors / 0 warnings) [branch: MDL-65355-main | CI Job ] More information about this report Built on: Sun Dec 15 10:58:16 PM UTC 2024

      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

        1. demo.moodle.net_error.png
          demo.moodle.net_error.png
          17 kB
        2. image001.png
          image001.png
          6 kB
        3. image005.png
          image005.png
          0.6 kB
        4. Screenshot 2023-11-18 114947.png
          Screenshot 2023-11-18 114947.png
          2 kB
        5. searching for amp.png
          searching for amp.png
          40 kB

            rhell4 Rossco Hellmans
            pead Adrian Perez
            Kevin Pham Kevin Pham
            Ilya Tregubov Ilya Tregubov
            Votes:
            3 Vote for this issue
            Watchers:
            17 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 34 minutes
                34m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.