function editor_filter_xss

Same name and namespace in other branches
  1. 10 core/modules/editor/editor.module \editor_filter_xss()
  2. 9 core/modules/editor/editor.module \editor_filter_xss()
  3. 8.9.x core/modules/editor/editor.module \editor_filter_xss()
  4. main core/modules/editor/editor.module \editor_filter_xss()

Applies text editor XSS filtering.

Parameters

string $html: The HTML string that will be passed to the text editor.

\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.

\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 value

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 also

https://www.drupal.org/node/3568146

https://www.drupal.org/node/2099741

File

core/modules/editor/editor.module, line 123

Code

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);
}

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