view core/lib/Drupal/Component/Render/PlainTextOutput.php @ 13:5fb285c0d0e3

Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've been lucky to get away with this so far, as we don't support self-registration which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5 was vulnerable to.
author Chris Cannam
date Mon, 23 Apr 2018 09:33:26 +0100
parents 4c8ae668cc8c
children
line wrap: on
line source
<?php

namespace Drupal\Component\Render;

use Drupal\Component\Utility\Html;

/**
 * Provides an output strategy for transforming HTML into simple plain text.
 *
 * Use this when rendering a given HTML string into a plain text string that
 * does not need special formatting, such as a label or an email subject.
 *
 * Returns a string with HTML tags stripped and HTML entities decoded suitable
 * for email or other non-HTML contexts.
 */
class PlainTextOutput implements OutputStrategyInterface {

  /**
   * {@inheritdoc}
   */
  public static function renderFromHtml($string) {
    return Html::decodeEntities(strip_tags((string) $string));
  }

}