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

MIME type is incorrect in Database Javascript template script




      The MIME type set in the header of the output of the Javascript template from the Database activity is text/css. This is OK in most cases, but Chrome now strictly refuses to execute the Javascript because the MIME type is incorrect. The correct MIME type should be application/javascript.

      Replication steps:

      1. Log in as teacher/admin
      2. Create/reuse a Database activity
      3. Click the Templates tab
      4. Click the Javascript template tab
      5. Add some JS, eg alert('hello');
      6. View the activity in Chrome

      Expected result
      The script will execute

      Actual result
      No script executes and in the browser shows an error...

      Refused to execute script from 'https://XXX/mod/data/js.php?d=5' because its MIME type ('text/css') is not executable, and strict MIME type checking is enabled.

      It looks like this change was made as part of a large issue that set MIME types for many files around Moodle. The Javascript template script MIME type was set at the same time as the CSS template scripts. It hasn't been an issue up to now as browsers have been more permissive.

      The consequence is that many Database activity modules, with added Javascript, will break in Chrome.


          Issue Links



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


                • Created:
                  Fix Release Date: