function HandlerBase::sanitizeValue

Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::sanitizeValue()
  2. 10 core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::sanitizeValue()
  3. 8.9.x core/modules/views/src/Plugin/views/HandlerBase.php \Drupal\views\Plugin\views\HandlerBase::sanitizeValue()
2 calls to HandlerBase::sanitizeValue()
Title::preRender in core/modules/views/src/Plugin/views/area/Title.php
Performs any operations needed before full rendering.
Url::render in core/modules/views/src/Plugin/views/field/Url.php
Renders the field.

File

core/modules/views/src/Plugin/views/HandlerBase.php, line 197

Class

HandlerBase
Base class for Views handler plugins.

Namespace

Drupal\views\Plugin\views

Code

public function sanitizeValue($value, $type = NULL) {
  if ($value === NULL) {
    return '';
  }
  switch ($type) {
    case 'xss':
      $value = Xss::filter($value);
      break;

    case 'xss_admin':
      $value = Xss::filterAdmin($value);
      break;

    case 'url':
      $value = Html::escape(UrlHelper::stripDangerousProtocols($value));
      break;

    default:
      $value = Html::escape($value);
      break;

  }
  return ViewsRenderPipelineMarkup::create($value);
}

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