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

Make filter_save_ignore_tags safe to use with format_text and forceclean

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 4.4
    • Filters

      As commented by Eloy here and here function filter_save_ignore_tags() is not so safe and would not work in the scenario:

          filter_save_ignore_tags($template, array('\[\[', '##'), array('\]\]', '##'), $extracted);
          $filteredtemplate = format_text($template, FORMAT_HTML, ['context' => $context]);
          if (!empty($extracted)) { 
              $extracted = array_reverse($extracted); // Reversed to recover in order (in case any nesting happened).
              $filteredtemplate = str_replace(array_keys($extracted), $extracted, $filteredtemplate);
          } 
      

      What it does:

      • extract special placeholders
      • apply format_text
      • restore special placeholders in the formatted text

      Eloy also suggested to use a different syntax for temporary replacements, not using angle brackets, so format_text() does not strip them out

            marina Marina Glancy
            marina Marina Glancy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

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

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