diff --git a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php index 336c318..95b1864 100644 --- a/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php +++ b/core/lib/Drupal/Core/Field/AllowedTagsXssTrait.php @@ -34,7 +34,7 @@ * valid UTF-8. */ public function fieldFilterXss($string) { - return new FieldFilteredString($string); + return FieldFilteredString::create($string); } /** diff --git a/core/lib/Drupal/Core/Field/FieldFilteredString.php b/core/lib/Drupal/Core/Field/FieldFilteredString.php index 944e38b..c3fca4d 100644 --- a/core/lib/Drupal/Core/Field/FieldFilteredString.php +++ b/core/lib/Drupal/Core/Field/FieldFilteredString.php @@ -14,7 +14,7 @@ use Drupal\Component\Utility\Xss; /** - * Defines an object that passes safe strings through the Filter system. + * Defines an object that passes safe strings through the Field system. * * This object should only be constructed with a known safe string. If there is * any risk that the string contains user-entered data that has not been @@ -58,13 +58,13 @@ public static function create($string) { } /** - * Returns a list of tags allowed by AllowedTagsXssTrait::fieldFilterXss(). + * Returns the allowed tag list. * * @return string[] * A list of allowed tags. */ public static function allowedTags() { - return array('a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img'); + return ['a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img']; } /** diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php index c4a6ae4..0172bdb 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/NumberWidget.php @@ -102,11 +102,11 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen // Add prefix and suffix. if ($field_settings['prefix']) { $prefixes = explode('|', $field_settings['prefix']); - $element['#field_prefix'] = new FieldFilteredString(array_pop($prefixes)); + $element['#field_prefix'] = FieldFilteredString::create(array_pop($prefixes)); } if ($field_settings['suffix']) { $suffixes = explode('|', $field_settings['suffix']); - $element['#field_suffix'] = new FieldFilteredString(array_pop($suffixes)); + $element['#field_suffix'] = FieldFilteredString::create(array_pop($suffixes)); } return array('value' => $element); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php index 5a294c0..84b7d2c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/OptionsWidgetBase.php @@ -191,7 +191,7 @@ protected function supportsGroups() { */ protected function sanitizeLabel(&$label) { // Allow a limited set of HTML tags. - $label = new FieldFilteredString($label); + $label = FieldFilteredString::create($label); } /** diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 4ddb892..444525f 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -86,7 +86,7 @@ public function form(FieldItemListInterface $items, array &$form, FormStateInter $delta = isset($get_delta) ? $get_delta : 0; $element = array( '#title' => SafeMarkup::checkPlain($this->fieldDefinition->getLabel()), - '#description' => new FieldFilteredString(\Drupal::token()->replace($this->fieldDefinition->getDescription())), + '#description' => FieldFilteredString::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())), ); $element = $this->formSingleElement($items, $delta, $element, $form, $form_state); @@ -165,7 +165,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } $title = SafeMarkup::checkPlain($this->fieldDefinition->getLabel()); - $description = new FieldFilteredString(\Drupal::token()->replace($this->fieldDefinition->getDescription())); + $description = FieldFilteredString::create(\Drupal::token()->replace($this->fieldDefinition->getDescription())); $elements = array(); diff --git a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php index 58154ab..fb69d9c 100644 --- a/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/src/Plugin/Field/FieldWidget/FileWidget.php @@ -120,7 +120,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f } $title = SafeMarkup::checkPlain($this->fieldDefinition->getLabel()); - $description = new FieldFilteredString($this->fieldDefinition->getDescription()); + $description = FieldFilteredString::create($this->fieldDefinition->getDescription()); $elements = array(); diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php index 76637a6..0a69144 100644 --- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php +++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php @@ -98,7 +98,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f if ($cardinality == 1) { // If there's only one field, return it as delta 0. if (empty($elements[0]['#default_value']['fids'])) { - $file_upload_help['#description'] = new FieldFilteredString($this->fieldDefinition->getDescription()); + $file_upload_help['#description'] = FieldFilteredString::create($this->fieldDefinition->getDescription()); $elements[0]['#description'] = \Drupal::service('renderer')->renderPlain($file_upload_help); } } diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php index 71eaa64..0b61f44 100644 --- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php +++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsDefaultFormatter.php @@ -50,7 +50,7 @@ public function viewElements(FieldItemListInterface $items) { // the associated label, otherwise just display the raw value. $output = isset($options[$value]) ? $options[$value] : $value; // @todo convert to markup using the tag list. - $elements[$delta] = array('#markup' => New FieldFilteredString($output)); + $elements[$delta] = array('#markup' => FieldFilteredString::create($output)); } } diff --git a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php index 42aa2df..8c78816 100644 --- a/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php +++ b/core/modules/options/src/Plugin/Field/FieldFormatter/OptionsKeyFormatter.php @@ -36,7 +36,7 @@ public function viewElements(FieldItemListInterface $items) { foreach ($items as $delta => $item) { // @todo convert to markup using the tag list. - $elements[$delta] = array('#markup' => New FieldFilteredString($output)); + $elements[$delta] = array('#markup' => FieldFilteredString::create($output)); } return $elements; diff --git a/core/modules/options/src/Plugin/views/argument/NumberListField.php b/core/modules/options/src/Plugin/views/argument/NumberListField.php index bf63206..4e22f9c 100644 --- a/core/modules/options/src/Plugin/views/argument/NumberListField.php +++ b/core/modules/options/src/Plugin/views/argument/NumberListField.php @@ -81,7 +81,7 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it. if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { - return new FieldFilteredString($this->allowedValues[$value]); + return FieldFilteredString::create($this->allowedValues[$value]); } // Else, fallback to the key. else { diff --git a/core/modules/options/src/Plugin/views/argument/StringListField.php b/core/modules/options/src/Plugin/views/argument/StringListField.php index 8dd788e..7a39b35 100644 --- a/core/modules/options/src/Plugin/views/argument/StringListField.php +++ b/core/modules/options/src/Plugin/views/argument/StringListField.php @@ -81,12 +81,12 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it. if (isset($this->allowedValues[$value]) && !empty($this->options['summary']['human'])) { - $value = new FieldFilteredString($this->allowedValues[$value]); + $value = FieldFilteredString::create($this->allowedValues[$value]); } // Else, fallback to the key. else { - // Filtered an escaped string will not change it. - $value = new FieldFilteredString(SafeMarkup::checkPlain($value)); + // Filtering an escaped string will not change it. + $value = FieldFilteredString::create(SafeMarkup::checkPlain($value)); } return $value->caseTransform($this->options['case']); } diff --git a/core/modules/views/src/Plugin/views/argument/FieldList.php b/core/modules/views/src/Plugin/views/argument/FieldList.php index 0aec21a..36c50ac 100644 --- a/core/modules/views/src/Plugin/views/argument/FieldList.php +++ b/core/modules/views/src/Plugin/views/argument/FieldList.php @@ -71,7 +71,7 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it, if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { - return new FieldFilteredString($this->allowed_values[$value]); + return FieldFilteredString::create($this->allowed_values[$value]); } // else fallback to the key. else { diff --git a/core/modules/views/src/Plugin/views/argument/ListString.php b/core/modules/views/src/Plugin/views/argument/ListString.php index e93f9b6..83419eb 100644 --- a/core/modules/views/src/Plugin/views/argument/ListString.php +++ b/core/modules/views/src/Plugin/views/argument/ListString.php @@ -73,12 +73,12 @@ public function summaryName($data) { $value = $data->{$this->name_alias}; // If the list element has a human readable name show it, if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) { - $value = new FieldFilteredString($this->allowed_values[$value]); + $value = FieldFilteredString::create($this->allowed_values[$value]); } // else fallback to the key. else { - // Filtered an escaped string will not change it. - $value = new FieldFilteredString(SafeMarkup::checkPlain($value)); + // Filtering an escaped string will not change it. + $value = FieldFilteredString::create(SafeMarkup::checkPlain($value)); } return $value->caseTransform($this->options['case']); }