function text_sanitize

Sanitizes the 'value' or 'summary' data of a text value.

Depending on whether the field instance uses text processing, data is run through check_plain() or check_markup().

Parameters

bool $text_processing: Whether to process the text via check_markup().

string $langcode: The language associated with $item.

array $item: The field value to sanitize.

string $column: The column to sanitize (either 'value' or 'summary').

Return value

string The sanitized string.

6 calls to text_sanitize()
hook_field_load in drupal/core/modules/field/field.api.php
Define custom load behavior for this module's field types.
NodeTokenReplaceTest::testNodeTokenReplacement in drupal/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
Creates a node, then tests the tokens generated from it.
node_tokens in drupal/core/modules/node/node.tokens.inc
Implements hook_tokens().
TextDefaultFormatter::viewElements in drupal/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextDefaultFormatter.php
Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
TextTrimmedFormatter::viewElements in drupal/core/modules/text/lib/Drupal/text/Plugin/field/formatter/TextTrimmedFormatter.php
Builds a renderable array for a field value.

... See full list

File

drupal/core/modules/text/text.module, line 219
Defines simple text field types.

Code

function text_sanitize($text_processing, $langcode, $item, $column) {

  // If the value uses a cacheable text format, text_field_load() precomputes
  // the sanitized string.
  if (isset($item["safe_{$column}"])) {
    return $item["safe_{$column}"];
  }
  if ($text_processing) {
    return check_markup($item[$column], $item['format'], $langcode);
  }

  // Escape all HTML and retain newlines.
  // @see \Drupal\text\Plugin\field\formatter\TextPlainFormatter
  return nl2br(check_plain($item[$column]));
}