-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.4.1
-
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 ?