Commit 3a42e91d authored by webchick's avatar webchick

Issue #2089331 by grom358 | thedavidmeister: [meta] Replace calls to...

Issue #2089331 by grom358 | thedavidmeister: [meta] Replace calls to check_plain() with Drupal\Component\Utility\String::checkPlain().
parent 432b5a78
...@@ -195,7 +195,7 @@ public function form(array $form, array &$form_state) { ...@@ -195,7 +195,7 @@ public function form(array $form, array &$form_state) {
} }
// Per-role visibility. // Per-role visibility.
$role_options = array_map('check_plain', user_role_names()); $role_options = array_map(array('\Drupal\Component\Utility\String', 'checkPlain'), user_role_names());
$form['visibility']['role'] = array( $form['visibility']['role'] = array(
'#type' => 'details', '#type' => 'details',
'#title' => $this->t('Roles'), '#title' => $this->t('Roles'),
......
...@@ -65,7 +65,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la ...@@ -65,7 +65,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
// @todo Remove after fixing http://drupal.org/node/1989568. // @todo Remove after fixing http://drupal.org/node/1989568.
'#block' => $entity, '#block' => $entity,
); );
$build[$entity_id]['#configuration']['label'] = check_plain($configuration['label']); $build[$entity_id]['#configuration']['label'] = String::checkPlain($configuration['label']);
// Set cache tags; these always need to be set, whether the block is // Set cache tags; these always need to be set, whether the block is
// cacheable or not, so that the page cache is correctly informed. // cacheable or not, so that the page cache is correctly informed.
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
use Drupal\comment\CommentInterface; use Drupal\comment\CommentInterface;
use Drupal\comment\Entity\Comment; use Drupal\comment\Entity\Comment;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\entity\Entity\EntityViewDisplay; use Drupal\entity\Entity\EntityViewDisplay;
...@@ -1265,7 +1266,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) { ...@@ -1265,7 +1266,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) {
if (!empty($account) && $account->isAuthenticated()) { if (!empty($account) && $account->isAuthenticated()) {
$comment->setOwner($account); $comment->setOwner($account);
$comment->setAuthorName(check_plain($account->getUsername())); $comment->setAuthorName(String::checkPlain($account->getUsername()));
} }
elseif (empty($author_name)) { elseif (empty($author_name)) {
$comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous')); $comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous'));
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Builds placeholder replacement tokens for comment-related data. * Builds placeholder replacement tokens for comment-related data.
*/ */
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Xss;
/** /**
...@@ -141,12 +142,12 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = ...@@ -141,12 +142,12 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
// Poster identity information for comments. // Poster identity information for comments.
case 'hostname': case 'hostname':
$replacements[$original] = $sanitize ? check_plain($comment->getHostname()) : $comment->getHostname(); $replacements[$original] = $sanitize ? String::checkPlain($comment->getHostname()) : $comment->getHostname();
break; break;
case 'mail': case 'mail':
$mail = $comment->getAuthorEmail(); $mail = $comment->getAuthorEmail();
$replacements[$original] = $sanitize ? check_plain($mail) : $mail; $replacements[$original] = $sanitize ? String::checkPlain($mail) : $mail;
break; break;
case 'homepage': case 'homepage':
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\argument; namespace Drupal\comment\Plugin\views\argument;
use Drupal\Component\Utility\String;
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Drupal\views\Plugin\views\argument\ArgumentPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -64,7 +65,7 @@ function title() { ...@@ -64,7 +65,7 @@ function title() {
return t('No user'); return t('No user');
} }
return check_plain($title); return String::checkPlain($title);
} }
protected function defaultActions($which = NULL) { protected function defaultActions($which = NULL) {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests; namespace Drupal\comment\Tests;
use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Xss; use Drupal\Component\Utility\Xss;
/** /**
...@@ -53,10 +54,10 @@ function testCommentTokenReplacement() { ...@@ -53,10 +54,10 @@ function testCommentTokenReplacement() {
// Generate and test sanitized tokens. // Generate and test sanitized tokens.
$tests = array(); $tests = array();
$tests['[comment:cid]'] = $comment->id(); $tests['[comment:cid]'] = $comment->id();
$tests['[comment:hostname]'] = check_plain($comment->getHostname()); $tests['[comment:hostname]'] = String::checkPlain($comment->getHostname());
$tests['[comment:name]'] = Xss::filter($comment->getAuthorName()); $tests['[comment:name]'] = Xss::filter($comment->getAuthorName());
$tests['[comment:author]'] = Xss::filter($comment->getAuthorName()); $tests['[comment:author]'] = Xss::filter($comment->getAuthorName());
$tests['[comment:mail]'] = check_plain($this->admin_user->getEmail()); $tests['[comment:mail]'] = String::checkPlain($this->admin_user->getEmail());
$tests['[comment:homepage]'] = check_url($comment->getHomepage()); $tests['[comment:homepage]'] = check_url($comment->getHomepage());
$tests['[comment:title]'] = Xss::filter($comment->getSubject()); $tests['[comment:title]'] = Xss::filter($comment->getSubject());
$tests['[comment:body]'] = $comment->comment_body->processed; $tests['[comment:body]'] = $comment->comment_body->processed;
...@@ -65,11 +66,11 @@ function testCommentTokenReplacement() { ...@@ -65,11 +66,11 @@ function testCommentTokenReplacement() {
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id); $tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->getCreatedTime(), 2, $language_interface->id);
$tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id); $tests['[comment:changed:since]'] = format_interval(REQUEST_TIME - $comment->getChangedTime(), 2, $language_interface->id);
$tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL; $tests['[comment:parent:cid]'] = $comment->hasParentComment() ? $comment->getParentComment()->id() : NULL;
$tests['[comment:parent:title]'] = check_plain($parent_comment->getSubject()); $tests['[comment:parent:title]'] = String::checkPlain($parent_comment->getSubject());
$tests['[comment:node:nid]'] = $comment->getCommentedEntityId(); $tests['[comment:node:nid]'] = $comment->getCommentedEntityId();
$tests['[comment:node:title]'] = check_plain($node->getTitle()); $tests['[comment:node:title]'] = String::checkPlain($node->getTitle());
$tests['[comment:author:uid]'] = $comment->getOwnerId(); $tests['[comment:author:uid]'] = $comment->getOwnerId();
$tests['[comment:author:name]'] = check_plain($this->admin_user->getUsername()); $tests['[comment:author:name]'] = String::checkPlain($this->admin_user->getUsername());
// Test to make sure that we generated something for each token. // Test to make sure that we generated something for each token.
$this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.');
......
...@@ -190,7 +190,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { ...@@ -190,7 +190,7 @@ public function instanceSettingsForm(array $form, array &$form_state) {
// entity type specific plugins (e.g. 'default_node', 'default_user', // entity type specific plugins (e.g. 'default_node', 'default_user',
// ...). // ...).
if (in_array($plugin_id, $handler_groups)) { if (in_array($plugin_id, $handler_groups)) {
$handlers_options[$plugin_id] = check_plain($plugin['label']); $handlers_options[$plugin_id] = String::checkPlain($plugin['label']);
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Plugin\Field\FieldFormatter; namespace Drupal\entity_reference\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
/** /**
...@@ -77,7 +78,7 @@ public function viewElements(FieldItemListInterface $items) { ...@@ -77,7 +78,7 @@ public function viewElements(FieldItemListInterface $items) {
) + $uri->toRenderArray(); ) + $uri->toRenderArray();
} }
else { else {
$elements[$delta] = array('#markup' => check_plain($label)); $elements[$delta] = array('#markup' => String::checkPlain($label));
} }
$elements[$delta]['#cache']['tags'] = $referenced_entity->getCacheTag(); $elements[$delta]['#cache']['tags'] = $referenced_entity->getCacheTag();
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Plugin\entity_reference\selection; namespace Drupal\entity_reference\Plugin\entity_reference\selection;
use Drupal\Component\Utility\String;
use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
...@@ -183,7 +184,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA ...@@ -183,7 +184,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA
$entities = entity_load_multiple($target_type, $result); $entities = entity_load_multiple($target_type, $result);
foreach ($entities as $entity_id => $entity) { foreach ($entities as $entity_id => $entity) {
$bundle = $entity->bundle(); $bundle = $entity->bundle();
$options[$bundle][$entity_id] = check_plain($entity->label()); $options[$bundle][$entity_id] = String::checkPlain($entity->label());
} }
return $options; return $options;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests; namespace Drupal\entity_reference\Tests;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
use Drupal\comment\CommentInterface; use Drupal\comment\CommentInterface;
...@@ -114,7 +115,7 @@ public function testNodeHandler() { ...@@ -114,7 +115,7 @@ public function testNodeHandler() {
$node = entity_create('node', $values); $node = entity_create('node', $values);
$node->save(); $node->save();
$nodes[$key] = $node; $nodes[$key] = $node;
$node_labels[$key] = check_plain($node->label()); $node_labels[$key] = String::checkPlain($node->label());
} }
// Test as a non-admin. // Test as a non-admin.
...@@ -260,7 +261,7 @@ public function testUserHandler() { ...@@ -260,7 +261,7 @@ public function testUserHandler() {
$account = $values; $account = $values;
} }
$users[$key] = $account; $users[$key] = $account;
$user_labels[$key] = check_plain($account->getUsername()); $user_labels[$key] = String::checkPlain($account->getUsername());
} }
// Test as a non-admin. // Test as a non-admin.
...@@ -439,7 +440,7 @@ public function testCommentHandler() { ...@@ -439,7 +440,7 @@ public function testCommentHandler() {
$comment = entity_create('comment', $values); $comment = entity_create('comment', $values);
$comment->save(); $comment->save();
$comments[$key] = $comment; $comments[$key] = $comment;
$comment_labels[$key] = check_plain($comment->label()); $comment_labels[$key] = String::checkPlain($comment->label());
} }
// Test as a non-admin. // Test as a non-admin.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\entity_reference\Tests; namespace Drupal\entity_reference\Tests;
use Drupal\Component\Utility\String;
use Drupal\simpletest\WebTestBase; use Drupal\simpletest\WebTestBase;
/** /**
...@@ -115,7 +116,7 @@ public function testSort() { ...@@ -115,7 +116,7 @@ public function testSort() {
$node = entity_create('node', $values); $node = entity_create('node', $values);
$node->save(); $node->save();
$nodes[$key] = $node; $nodes[$key] = $node;
$node_labels[$key] = check_plain($node->label()); $node_labels[$key] = String::checkPlain($node->label());
} }
// Test as a non-admin. // Test as a non-admin.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\field\Plugin\views\argument; namespace Drupal\field\Plugin\views\argument;
use Drupal\Component\Utility\String;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\argument\Numeric; use Drupal\views\Plugin\views\argument\Numeric;
...@@ -69,7 +70,7 @@ public function summaryName($data) { ...@@ -69,7 +70,7 @@ public function summaryName($data) {
} }
// else fallback to the key. // else fallback to the key.
else { else {
return check_plain($value); return String::checkPlain($value);
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\field\Plugin\views\argument; namespace Drupal\field\Plugin\views\argument;
use Drupal\Component\Utility\String as UtilityString;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\argument\String; use Drupal\views\Plugin\views\argument\String;
...@@ -71,7 +72,7 @@ public function summaryName($data) { ...@@ -71,7 +72,7 @@ public function summaryName($data) {
} }
// else fallback to the key. // else fallback to the key.
else { else {
return $this->caseTransform(check_plain($value), $this->options['case']); return $this->caseTransform(UtilityString::checkPlain($value), $this->options['case']);
} }
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\field\Tests; namespace Drupal\field\Tests;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
/** /**
...@@ -107,7 +108,7 @@ function testFieldFormSingle() { ...@@ -107,7 +108,7 @@ function testFieldFormSingle() {
$this->drupalGet('entity_test/add'); $this->drupalGet('entity_test/add');
// Create token value expected for description. // Create token value expected for description.
$token_description = check_plain(\Drupal::config('system.site')->get('name')) . '_description'; $token_description = String::checkPlain(\Drupal::config('system.site')->get('name')) . '_description';
$this->assertText($token_description, 'Token replacement for description is displayed'); $this->assertText($token_description, 'Token replacement for description is displayed');
$this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); $this->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed');
$this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed'); $this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed');
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\field_ui; namespace Drupal\field_ui;
use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Utility\String;
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
...@@ -275,7 +276,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent ...@@ -275,7 +276,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
'defaultPlugin' => $this->getDefaultPlugin($field_definition->getType()), 'defaultPlugin' => $this->getDefaultPlugin($field_definition->getType()),
), ),
'human_name' => array( 'human_name' => array(
'#markup' => check_plain($label), '#markup' => String::checkPlain($label),
), ),
'weight' => array( 'weight' => array(
'#type' => 'textfield', '#type' => 'textfield',
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\field_ui; namespace Drupal\field_ui;
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\EntityListBuilderInterface; use Drupal\Core\Entity\EntityListBuilderInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
...@@ -125,7 +126,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL ...@@ -125,7 +126,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL
'id' => drupal_html_class($name), 'id' => drupal_html_class($name),
), ),
'label' => array( 'label' => array(
'#markup' => check_plain($instance->getLabel()), '#markup' => String::checkPlain($instance->getLabel()),
), ),
'field_name' => array( 'field_name' => array(
'#markup' => $instance->getName(), '#markup' => $instance->getName(),
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
*/ */
use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
...@@ -188,7 +189,7 @@ function theme_file_upload_help($variables) { ...@@ -188,7 +189,7 @@ function theme_file_upload_help($variables) {
$descriptions[] = t('!size limit.', array('!size' => format_size($upload_validators['file_validate_size'][0]))); $descriptions[] = t('!size limit.', array('!size' => format_size($upload_validators['file_validate_size'][0])));
} }
if (isset($upload_validators['file_validate_extensions'])) { if (isset($upload_validators['file_validate_extensions'])) {
$descriptions[] = t('Allowed types: !extensions.', array('!extensions' => check_plain($upload_validators['file_validate_extensions'][0]))); $descriptions[] = t('Allowed types: !extensions.', array('!extensions' => String::checkPlain($upload_validators['file_validate_extensions'][0])));
} }
if (isset($upload_validators['file_validate_image_resolution'])) { if (isset($upload_validators['file_validate_image_resolution'])) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Defines a "managed_file" Form API field and a "file" field for Field module. * Defines a "managed_file" Form API field and a "file" field for Field module.
*/ */
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\file\Entity\File; use Drupal\file\Entity\File;
...@@ -1048,15 +1049,15 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr ...@@ -1048,15 +1049,15 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr
// Essential file data // Essential file data
case 'name': case 'name':
$replacements[$original] = $sanitize ? check_plain($file->getFilename()) : $file->getFilename(); $replacements[$original] = $sanitize ? String::checkPlain($file->getFilename()) : $file->getFilename();
break; break;
case 'path': case 'path':
$replacements[$original] = $sanitize ? check_plain($file->getFileUri()) : $file->getFileUri(); $replacements[$original] = $sanitize ? String::checkPlain($file->getFileUri()) : $file->getFileUri();
break; break;
case 'mime': case 'mime':
$replacements[$original] = $sanitize ? check_plain($file->getMimeType()) : $file->getMimeType(); $replacements[$original] = $sanitize ? String::checkPlain($file->getMimeType()) : $file->getMimeType();
break; break;
case 'size': case 'size':
...@@ -1064,7 +1065,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr ...@@ -1064,7 +1065,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr
break; break;
case 'url': case 'url':
$replacements[$original] = $sanitize ? check_plain(file_create_url($file->getFileUri())) : file_create_url($file->getFileUri()); $replacements[$original] = $sanitize ? String::checkPlain(file_create_url($file->getFileUri())) : file_create_url($file->getFileUri());
break; break;
// These tokens are default variations on the chained tokens handled below. // These tokens are default variations on the chained tokens handled below.
...@@ -1078,7 +1079,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr ...@@ -1078,7 +1079,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr
case 'owner': case 'owner':
$name = $file->getOwner()->label(); $name = $file->getOwner()->label();
$replacements[$original] = $sanitize ? check_plain($name) : $name; $replacements[$original] = $sanitize ? String::checkPlain($name) : $name;
break; break;
} }
} }
...@@ -1626,7 +1627,7 @@ function theme_file_link($variables) { ...@@ -1626,7 +1627,7 @@ function theme_file_link($variables) {
} }
else { else {
$link_text = $variables['description']; $link_text = $variables['description'];
$options['attributes']['title'] = check_plain($file->getFilename()); $options['attributes']['title'] = String::checkPlain($file->getFilename());
} }
$file_icon = array( $file_icon = array(
...@@ -1654,7 +1655,7 @@ function theme_file_icon($variables) { ...@@ -1654,7 +1655,7 @@ function theme_file_icon($variables) {
$file = $variables['file']; $file = $variables['file'];
$icon_directory = $variables['icon_directory']; $icon_directory = $variables['icon_directory'];
$mime = check_plain($file->getMimeType()); $mime = String::checkPlain($file->getMimeType());
$icon_url = file_icon_url($file, $icon_directory); $icon_url = file_icon_url($file, $icon_directory);
return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />'; return '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />';
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
namespace Drupal\file\Plugin\Field\FieldWidget; namespace Drupal\file\Plugin\Field\FieldWidget;
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\WidgetBase; use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Field\FieldItemListInterface;
...@@ -94,7 +95,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f ...@@ -94,7 +95,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f
break; break;
} }
$title = check_plain($this->fieldDefinition->getLabel()); $title = String::checkPlain($this->fieldDefinition->getLabel());
$description = field_filter_xss($this->fieldDefinition->getDescription()); $description = field_filter_xss($this->fieldDefinition->getDescription());
$elements = array(); $elements = array();
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
namespace Drupal\file\Tests; namespace Drupal\file\Tests;
use Drupal\Component\Utility\String;
/** /**
* Tests the file token replacement in strings. * Tests the file token replacement in strings.
*/ */
...@@ -46,16 +48,16 @@ function testFileTokenReplacement() { ...@@ -46,16 +48,16 @@ function testFileTokenReplacement() {
// Generate and test sanitized tokens. // Generate and test sanitized tokens.
$tests = array(); $tests = array();
$tests['[file:fid]'] = $file->id(); $tests['[file:fid]'] = $file->id();
$tests['[file:name]'] = check_plain($file->getFilename()); $tests['[file:name]'] = String::checkPlain($file->getFilename());
$tests['[file:path]'] = check_plain($file->getFileUri()); $tests['[file:path]'] = String::checkPlain($file->getFileUri());
$tests['[file:mime]'] = check_plain($file->getMimeType()); $tests['[file:mime]'] = String::checkPlain($file->getMimeType());
$tests['[file:size]'] = format_size($file->getSize()); $tests['[file:size]'] = format_size($file->getSize());
$tests['[file:url]'] = check_plain(file_create_url($file->getFileUri())); $tests['[file:url]'] = String::checkPlain(file_create_url($file->getFileUri()));
$tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->id); $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->id);
$tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->id); $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->id);
$tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id); $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->id);
$tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id); $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->id);
$tests['[file:owner]'] = check_plain(user_format_name($this->admin_user)); $tests['[file:owner]'] = String::checkPlain(user_format_name($this->admin_user));
$tests['[file:owner:uid]'] = $file->getOwnerId(); $tests['[file:owner:uid]'] = $file->getOwnerId();
// Test to make sure that we generated something for each token. // Test to make sure that we generated something for each token.
......
...@@ -984,8 +984,8 @@ function _filter_url_parse_full_links($match) { ...@@ -984,8 +984,8 @@ function _filter_url_parse_full_links($match) {
$i = 1; $i = 1;
$match[$i] = decode_entities($match[$i]); $match[$i] = decode_entities($match[$i]);
$caption = check_plain(_filter_url_trim($match[$i])); $caption = String::checkPlain(_filter_url_trim($match[$i]));
$match[$i] = check_plain($match[$i]); $match[$i] = String::checkPlain($match[$i]);
return '<a href="' . $match[$i] . '">' . $caption . '</a>'; return '<a href="' . $match[$i] . '">' . $caption . '</a>';
} }
...@@ -999,8 +999,8 @@ function _filter_url_parse_email_links($match) { ...@@ -999,8 +999,8 @@ function _filter_url_parse_email_links($match) {
$i = 0; $i = 0;
$match[$i] = decode_entities($match[$i]); $match[$i] = decode_entities($match[$i]);
$caption = check_plain(_filter_url_trim($match[$i])); $caption = String::checkPlain(_filter_url_trim($match[$i]));
$match[$i] = check_plain($match[$i]); $match[$i] = String::checkPlain($match[$i]);