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

core/dynamic_tabs JS is trying to add JS within JS

XMLWordPrintable

    • MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_401_STABLE, MOODLE_402_STABLE
    • MDL-78350-401
    • Hide
      1. Ensure web developer console is open in your browser
      2. Log in as admin
      3. Create a new user
      4. Navigate to Reports from user menu
      5. Create new report from Users report source
        • Include default setup = YES
      6. Confirm there is no console error, stating:

        Template JS contains a script tag. This is not allowed. Only raw JS should be present here.
        

      7. Switch to Audience tab
      8. Confirm there is no console error (same content as previous)
      9. Add the All users audience and save
      10. Confirm the audience was added
      11. Switch back to Editor tab
      12. Open Conditions panel
      13. Add User > First name condition
      14. Confirm there is no console error (same content as previous)
      15. Confirm the condition is added
      16. Set User > First name condition to Contains: Admin and apply
      17. Confirm only admin user is listed in report
      18. Press Reset all in Conditions panel and confirm the prompt
      19. Confirm there is no console error (same content as previous)
      20. Confirm all users are listed in the report
      21. Delete the User > First name condition and confirm the prompt
      22. Confirm there is no console error (same content as previous)
      23. Confirm the condition is removed
      24. Press Preview in the report
      25. Confirm there is no console error (same content as previous)
      26. Confirm when previewing that the report filters work
      27. Press Edit in the report
      28. Confirm there is no console error (same content as previous)
      29. Confirm you can still edit the report (add/move columns)
      Show
      Ensure web developer console is open in your browser Log in as admin Create a new user Navigate to Reports from user menu Create new report from Users report source Include default setup = YES Confirm there is no console error, stating: Template JS contains a script tag. This is not allowed. Only raw JS should be present here. Switch to Audience tab Confirm there is no console error (same content as previous) Add the All users audience and save Confirm the audience was added Switch back to Editor tab Open Conditions panel Add User > First name condition Confirm there is no console error (same content as previous) Confirm the condition is added Set User > First name condition to Contains: Admin and apply Confirm only admin user is listed in report Press Reset all in Conditions panel and confirm the prompt Confirm there is no console error (same content as previous) Confirm all users are listed in the report Delete the User > First name condition and confirm the prompt Confirm there is no console error (same content as previous) Confirm the condition is removed Press Preview in the report Confirm there is no console error (same content as previous) Confirm when previewing that the report filters work Press Edit in the report Confirm there is no console error (same content as previous) Confirm you can still edit the report (add/move columns)

      As identified by MDL-78266, core/dynamic_tabs is combining raw JS with JS contained in script tags. THIS IS WRONG!!!

      This comes from the following code:

              return Templates.replaceNodeContents(tab, html, js + tabjs);
      

      https://github.com/moodle/moodle/blob/5bef42d324630654497087ad42f8bebf0f97bf24/lib/amd/src/dynamic_tabs.js#L155

      In this case, the tabjs comes from a fragment call returned by the core_dynamic_tabs_get_content web service method fetched in https://github.com/moodle/moodle/blob/master/lib/amd/src/local/repository/dynamic_tabs.js#L33

      This returns js in the form:

      <script ..>
      //.. JS here
      </script>
      

      This utimately means we try to add a tag like:

      <script ...>
          <script ..>
              //.. JS here
          </script>
      </script>
      

      This is, of course, invalid.

      We need to re-evaluate how we add this JS.

            pholden Paul Holden
            dobedobedoh Andrew Lyons
            David Carrillo David Carrillo
            Andrew Lyons Andrew Lyons
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 19 minutes
                5h 19m

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