Commit fdf37cf3 authored by catch's avatar catch
Browse files

Issue #2958407 by alexpott: Properly deprecate SafeMarkup::isSafe,...

Issue #2958407 by alexpott: Properly deprecate SafeMarkup::isSafe, SafeMarkup::checkPlain and the SafeMarkup class
parent 68b8b52f
Loading
Loading
Loading
Loading
+2 −0
Changes for core/lib/Drupal/Component/Utility/SafeMarkup.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ class SafeMarkup {
   * @see https://www.drupal.org/node/2549395
   */
  public static function isSafe($string, $strategy = 'html') {
    @trigger_error('SafeMarkup::isSafe() is scheduled for removal in Drupal 9.0.0. Instead, you should just check if a variable is an instance of \Drupal\Component\Render\MarkupInterface. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
    return $string instanceof MarkupInterface;
  }

@@ -66,6 +67,7 @@ public static function isSafe($string, $strategy = 'html') {
   * @see drupal_validate_utf8()
   */
  public static function checkPlain($text) {
    @trigger_error('SafeMarkup::checkPlain() is scheduled for removal in Drupal 9.0.0. Rely on Twig\'s auto-escaping feature, or use the @link theme_render #plain_text @endlink key when constructing a render array that contains plain text in order to use the renderer\'s auto-escaping feature. If neither of these are possible, \Drupal\Component\Utility\Html::escape() can be used in places where explicit escaping is needed. See https://www.drupal.org/node/2549395.', E_USER_DEPRECATED);
    return new HtmlEscapedText($text);
  }

+0 −1
Changes for core/lib/Drupal/Core/Render/Markup.php: 0 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
 *
 * @see \Drupal\Core\Template\TwigExtension::escapeFilter
 * @see \Twig_Markup
 * @see \Drupal\Component\Utility\SafeMarkup
 */
final class Markup implements MarkupInterface, \Countable {
  use MarkupTrait;
+1 −1
Changes for core/lib/Drupal/Core/Template/TwigNodeVisitor.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ protected function doLeaveNode(\Twig_Node $node, \Twig_Environment $env) {
    elseif ($node instanceof \Twig_Node_Expression_Filter) {
      $name = $node->getNode('filter')->getAttribute('value');
      if ('escape' == $name || 'e' == $name) {
        // Use our own escape filter that is SafeMarkup aware.
        // Use our own escape filter that is MarkupInterface aware.
        $node->getNode('filter')->setAttribute('value', 'drupal_escape');

        // Store that we have a filter active already that knows
+2 −4
Changes for core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -37,8 +37,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
  protected $testLanguageSelector = TRUE;

  /**
   * Flag that tells whether the HTML escaping of all languages works or not
   * after SafeMarkup change.
   * Flag to determine if "all languages" rendering is tested.
   *
   * @var bool
   */
@@ -117,8 +116,7 @@ protected function doTestBasicTranslation() {
    ], ['language' => $language]);
    $this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), $this->getFormSubmitActionForNewTranslation($entity, $langcode));

    // Assert that HTML is escaped in "all languages" in UI after SafeMarkup
    // change.
    // Assert that HTML is not escaped unexpectedly.
    if ($this->testHTMLEscapeForAllLanguages) {
      $this->assertNoRaw('<span class="translation-entity-all-languages">(all languages)</span>');
      $this->assertRaw('<span class="translation-entity-all-languages">(all languages)</span>');
+2 −4
Changes for core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php: 2 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -35,8 +35,7 @@ abstract class ContentTranslationUITestBase extends ContentTranslationTestBase {
  protected $testLanguageSelector = TRUE;

  /**
   * Flag that tells whether the HTML escaping of all languages works or not
   * after SafeMarkup change.
   * Flag to determine if "all languages" rendering is tested.
   *
   * @var bool
   */
@@ -115,8 +114,7 @@ protected function doTestBasicTranslation() {
    ], ['language' => $language]);
    $this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), $this->getFormSubmitActionForNewTranslation($entity, $langcode));

    // Assert that HTML is escaped in "all languages" in UI after SafeMarkup
    // change.
    // Assert that HTML is not escaped unexpectedly.
    if ($this->testHTMLEscapeForAllLanguages) {
      $this->assertNoRaw('&lt;span class=&quot;translation-entity-all-languages&quot;&gt;(all languages)&lt;/span&gt;');
      $this->assertRaw('<span class="translation-entity-all-languages">(all languages)</span>');
Loading