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

Possible to ignore default TinyMCE extended_valid_elements

XMLWordPrintable

    • MOODLE_404_STABLE, MOODLE_405_STABLE, MOODLE_500_STABLE

      Prior to 4.5.2 release, the default extended_valid_elements in TinyMCE was:

      extended_valid_elements: 'script[*],p[*],i[*]'

      This was needed so that empty script, p or i (for fontawesome) tags do not get stripped out.

      In MDL-80953 and its backport MDL-83668, a new site-level setting was added to define the extended_valid_elements.

      Having a way to easily configure this is good but it presents 2 possible issues, mainly caused by this line in lib/editor/tiny/classes/editor.php:

      'extended_valid_elements' => $siteconfig->extended_valid_elements ?? 'script[*],p[*],i[*]',

       

      1. You could set $siteconfig->extended_valid_elements = 'span[*]', thinking you are adding span elements to the valid elements list. But now empty span tags are allowed, but script, p and i tags are no longer allowed. They have been accidentally excluded from the valid elements list.
      2. If you set the editor_tiny | extended_valid_elements, and then clear it by emptying the textbox, value of extended_valid_elements in the DB (config_plugins table) is "".
        So $siteconfig->extended_valid_elements = '';
        By clearing the setting, one would expect the default settings to be applied. But it only applies if the setting was never set (null).

      With this issue, its possible for TinyMCE to accidentally strip out content that should otherwise be allowed in Moodle, eg. FontAwesome icons.

      Even when a site-level extended_valid_elements is set, the default of 'script[*],p[*],i[*]' should also be maintained.

       

      The current workaround is to always include script[*],p[*],i[*] when setting the editor_tiny | extended_valid_elements setting.

            Unassigned Unassigned
            rjnl Rajneel Totaram
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:

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