From f772f12ec006722d44fa5f1193a4411b60eca804 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 12 Feb 2020 09:52:52 +0000
Subject: [PATCH] Issue #3111906 by himmatbhatia, alexpott, swatichouhan012,
 longwave: Remove deprecated AllowedTagsXssTrait

---
 .../Drupal/Core/Field/AllowedTagsXssTrait.php | 53 -------------------
 .../FieldFormatter/NumericFormatterBase.php   |  3 --
 core/lib/Drupal/Core/Field/WidgetBase.php     |  2 -
 .../field_ui/src/Form/FieldConfigEditForm.php |  3 --
 core/modules/options/options.module           |  4 +-
 .../OptionsDefaultFormatter.php               |  3 --
 .../FieldFormatter/OptionsKeyFormatter.php    |  3 --
 .../Plugin/Field/FieldType/ListItemBase.php   |  3 --
 .../Plugin/views/argument/NumberListField.php |  2 -
 .../Plugin/views/argument/StringListField.php |  2 -
 .../AllowedTagsXssTraitDeprecateTest.php      | 37 -------------
 11 files changed, 2 insertions(+), 113 deletions(-)
 delete mode 100644 core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
 delete mode 100644 core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php

diff --git a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
deleted file mode 100644
index d893e1b3bdbb..000000000000
--- a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-
-namespace Drupal\Core\Field;
-
-/**
- * Useful methods when dealing with displaying allowed tags.
- *
- * @deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use
- *   \Drupal\Core\Field\FieldFilteredMarkup instead.
- *
- * @see \Drupal\Core\Field\FieldFilteredMarkup
- */
-trait AllowedTagsXssTrait {
-
-  /**
-   * Filters an HTML string to prevent XSS vulnerabilities.
-   *
-   * Like \Drupal\Component\Utility\Xss::filterAdmin(), but with a shorter list
-   * of allowed tags.
-   *
-   * Used for items entered by administrators, like field descriptions, allowed
-   * values, where some (mainly inline) mark-up may be desired (so
-   * \Drupal\Component\Utility\Html::escape() is not acceptable).
-   *
-   * @param string $string
-   *   The string with raw HTML in it.
-   *
-   * @return \Drupal\Core\Field\FieldFilteredMarkup
-   *   An XSS safe version of $string, or an empty string if $string is not
-   *   valid UTF-8.
-   */
-  public function fieldFilterXss($string) {
-    @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::create() instead.', E_USER_DEPRECATED);
-    return FieldFilteredMarkup::create($string);
-  }
-
-  /**
-   * Returns a list of tags allowed by AllowedTagsXssTrait::fieldFilterXss().
-   */
-  public function allowedTags() {
-    @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::allowedTags() instead.', E_USER_DEPRECATED);
-    return FieldFilteredMarkup::allowedTags();
-  }
-
-  /**
-   * Returns a human-readable list of allowed tags for display in help texts.
-   */
-  public function displayAllowedTags() {
-    @trigger_error(__METHOD__ . ' is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::displayAllowedTags() instead.', E_USER_DEPRECATED);
-    return FieldFilteredMarkup::displayAllowedTags();
-  }
-
-}
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
index cf75facc8a16..bc3efc759266 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Core\Field\Plugin\Field\FieldFormatter;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Field\FieldItemListInterface;
 use Drupal\Core\Form\FormStateInterface;
@@ -12,8 +11,6 @@
  */
 abstract class NumericFormatterBase extends FormatterBase {
 
-  use AllowedTagsXssTrait;
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php
index c3b67ba0b76d..c43d93205b8b 100644
--- a/core/lib/Drupal/Core/Field/WidgetBase.php
+++ b/core/lib/Drupal/Core/Field/WidgetBase.php
@@ -19,8 +19,6 @@
  */
 abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface, ContainerFactoryPluginInterface {
 
-  use AllowedTagsXssTrait;
-
   /**
    * The field definition.
    *
diff --git a/core/modules/field_ui/src/Form/FieldConfigEditForm.php b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
index 6c740485cd3f..db8122c4d931 100644
--- a/core/modules/field_ui/src/Form/FieldConfigEditForm.php
+++ b/core/modules/field_ui/src/Form/FieldConfigEditForm.php
@@ -4,7 +4,6 @@
 
 use Drupal\Core\Entity\EntityForm;
 use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Url;
@@ -19,8 +18,6 @@
  */
 class FieldConfigEditForm extends EntityForm {
 
-  use AllowedTagsXssTrait;
-
   /**
    * The entity being used by this form.
    *
diff --git a/core/modules/options/options.module b/core/modules/options/options.module
index 0face469bdfc..a0f586fa4d4e 100644
--- a/core/modules/options/options.module
+++ b/core/modules/options/options.module
@@ -52,8 +52,8 @@ function options_field_storage_config_delete(FieldStorageConfigInterface $field_
  * Returns the array of allowed values for a list field.
  *
  * The strings are not safe for output. Keys and values of the array should be
- * sanitized through \Drupal\Core\Field\AllowedTagsXssTrait::fieldFilterXss()
- * before being displayed.
+ * sanitized through \Drupal\Core\Field\FieldFilteredMarkup before being
+ * displayed.
  *
  * @param \Drupal\Core\Field\FieldStorageDefinitionInterface $definition
  *   The field storage definition.
diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
index ba1ba9c2b3c3..5ad9539d3ea4 100644
--- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
+++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\Field\FieldFormatter;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Field\FieldItemListInterface;
@@ -23,8 +22,6 @@
  */
 class OptionsDefaultFormatter extends FormatterBase {
 
-  use AllowedTagsXssTrait;
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
index 64f22e9b442e..9a9165219a37 100644
--- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
+++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\Field\FieldFormatter;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Field\FieldItemListInterface;
@@ -22,8 +21,6 @@
  */
 class OptionsKeyFormatter extends FormatterBase {
 
-  use AllowedTagsXssTrait;
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
index 3b29b04b816d..f7b95dfd1e9d 100644
--- a/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
+++ b/core/modules/options/src/Plugin/Field/FieldType/ListItemBase.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\Field\FieldType;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldDefinitionInterface;
 use Drupal\Core\Field\FieldItemBase;
 use Drupal\Core\Form\FormStateInterface;
@@ -15,8 +14,6 @@
  */
 abstract class ListItemBase extends FieldItemBase implements OptionsProviderInterface {
 
-  use AllowedTagsXssTrait;
-
   /**
    * {@inheritdoc}
    */
diff --git a/core/modules/options/src/Plugin/views/argument/NumberListField.php b/core/modules/options/src/Plugin/views/argument/NumberListField.php
index d3deeacc78dc..3a94c7bdd89f 100644
--- a/core/modules/options/src/Plugin/views/argument/NumberListField.php
+++ b/core/modules/options/src/Plugin/views/argument/NumberListField.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\views\argument;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\FieldAPIHandlerTrait;
@@ -20,7 +19,6 @@
  */
 class NumberListField extends NumericArgument {
 
-  use AllowedTagsXssTrait;
   use FieldAPIHandlerTrait;
 
   /**
diff --git a/core/modules/options/src/Plugin/views/argument/StringListField.php b/core/modules/options/src/Plugin/views/argument/StringListField.php
index 93c43a05eed8..b6642d267e8f 100644
--- a/core/modules/options/src/Plugin/views/argument/StringListField.php
+++ b/core/modules/options/src/Plugin/views/argument/StringListField.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\options\Plugin\views\argument;
 
-use Drupal\Core\Field\AllowedTagsXssTrait;
 use Drupal\Core\Field\FieldFilteredMarkup;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\views\FieldAPIHandlerTrait;
@@ -19,7 +18,6 @@
  */
 class StringListField extends StringArgument {
 
-  use AllowedTagsXssTrait;
   use FieldAPIHandlerTrait;
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php b/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php
deleted file mode 100644
index d018e154c109..000000000000
--- a/core/tests/Drupal/Tests/Core/Field/AllowedTagsXssTraitDeprecateTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-namespace Drupal\Tests\Core\Field;
-
-use Drupal\Core\Field\AllowedTagsXssTrait;
-use Drupal\Core\Field\FieldFilteredMarkup;
-use Drupal\Tests\UnitTestCase;
-
-/**
- * Tests AllowedTagsXssTrait.
- *
- * @group field
- * @group legacy
- */
-class AllowedTagsXssTraitDeprecateTest extends UnitTestCase {
-
-  /**
-   * @expectedDeprecation Drupal\Core\Field\AllowedTagsXssTrait::fieldFilterXss is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::create() instead.
-   * @expectedDeprecation Drupal\Core\Field\AllowedTagsXssTrait::allowedTags is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::allowedTags() instead.
-   * @expectedDeprecation Drupal\Core\Field\AllowedTagsXssTrait::displayAllowedTags is deprecated in drupal:8.0.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Field\FieldFilteredMarkup::displayAllowedTags() instead.
-   */
-  public function testDeprecation() {
-    $deprecated = new FieldDeprecateAllowedTagsXssTraitClass();
-    $this->assertSame('Test string', (string) $deprecated->fieldFilterXss('<object>Test string</object>'));
-    $this->assertSame(FieldFilteredMarkup::allowedTags(), $deprecated->allowedTags());
-    $this->assertSame(FieldFilteredMarkup::displayAllowedTags(), $deprecated->displayAllowedTags());
-  }
-
-}
-
-/**
- * Class FieldDeprecateAllowedTagsXssTraitClass
- */
-class FieldDeprecateAllowedTagsXssTraitClass {
-  use AllowedTagsXssTrait;
-
-}
-- 
GitLab