editor.module

Same filename and directory in other branches
  1. 11.x core/modules/editor/editor.module
  2. 10 core/modules/editor/editor.module
  3. 9 core/modules/editor/editor.module
  4. 8.9.x core/modules/editor/editor.module

File

core/modules/editor/editor.module

View source
<?php


/**
 * @file
 */

use Drupal\filter\FilterFormatInterface;

/**
 * Applies text editor XSS filtering.
 *
 * @param string $html
 *   The HTML string that will be passed to the text editor.
 * @param \Drupal\filter\FilterFormatInterface|null $format
 *   The text format whose text editor will be used or NULL if the previously
 *   defined text format is now disabled.
 * @param \Drupal\filter\FilterFormatInterface|null $original_format
 *   (optional) The original text format (i.e. when switching text formats,
 *   $format is the text format that is going to be used, $original_format is
 *   the one that was being used initially, the one that is stored in the
 *   database when editing).
 *
 * @return string|false
 *   The XSS filtered string or FALSE when no XSS filtering needs to be applied,
 *   because one of the next conditions might occur:
 *   - No text editor is associated with the text format,
 *   - The previously defined text format is now disabled,
 *   - The text editor is safe from XSS,
 *   - The text format does not use any XSS protection filters.
 *
 * @deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Instead, use
 *   the method ::filterXss() from the element.editor service.
 *
 * @see https://www.drupal.org/node/3568146
 * @see https://www.drupal.org/node/2099741
 */
function editor_filter_xss($html, ?FilterFormatInterface $format = NULL, ?FilterFormatInterface $original_format = NULL) {
  @trigger_error(__FUNCTION__ . '() is deprecated in drupal:11.4.0 and is removed from drupal:13.0.0. Instead, use the method ::filterXss() from the element.editor service. See https://www.drupal.org/node/3568146', E_USER_DEPRECATED);
  return \Drupal::service('element.editor')->filterXss($html, $format, $original_format);
}

Functions

Title Deprecated Summary
editor_filter_xss

in drupal:11.4.0 and is removed from drupal:13.0.0. Instead, use the method ::filterXss() from the element.editor service.

Applies text editor XSS filtering.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.