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

HTML Tidy filter breaks <script> elements on course pages

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.4.1
    • Filters
    • MOODLE_404_STABLE

      I only started noticing this one with 4.4.1+ build 20240719 reminding me that I needed to install php_tidy for the  HTML Tidy filter to actually work.

      If you have HTML Tidy enabled, its adds <![CDATA[ ]]> tags inside the script element, breaking any code that might be there.

      Steps to reproduce:

      • On a course, ensure the HTML Tidy filter is enabled.
      • To that course, add a page resource.
      • In the page content, ensure you are viewing the source code (or use plain text editor)
      • Add the following script

      <script>
        console.log('Hello World!');
      </script>  

       

      • Save and display the page.
      • In the browser console, note the error Uncaught SyntaxError: expected expression, got '<'
      • View the error code to see the following:

      <script>
         [CDATA[    console.log('Hello World);
        ]]>
        </script>  

       

      • Disable the HTML Tidy filter for this course.
      • View the page resource again and see the correct output in the console.

      As a potential solution, I do wonder if this filter should have output-html => true and output-xhtml => false ?

            Unassigned Unassigned
            bobg Bob Gilmore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

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