diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 6d7d9a5..c5ca01e 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -10,10 +10,11 @@ * book page, user etc. */ -use Drupal\Core\Entity\EntityInterface; +use Drupal\Component\Utility\String; +use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityChangedInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\comment\CommentInterface; -use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\field\FieldInstanceInterface; use Drupal\field\FieldInterface; use Drupal\file\FileInterface; @@ -1300,7 +1301,7 @@ function comment_preview(CommentInterface $comment, array &$form_state) { if (!empty($account) && $account->isAuthenticated()) { $comment->setOwner($account); - $comment->setAuthorName(check_plain($account->getUsername())); + $comment->setAuthorName(String::checkPlain($account->getUsername())); } elseif (empty($author_name)) { $comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous')); diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index ecff337..bf5a3e2 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -5,6 +5,8 @@ * Builds placeholder replacement tokens for comment-related data. */ +use Drupal\Component\Utility\String; + /** * Implements hook_token_info(). */ @@ -139,7 +141,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = // Poster identity information for comments. case 'hostname': - $replacements[$original] = $sanitize ? check_plain($comment->getHostname()) : $comment->getHostname(); + $replacements[$original] = $sanitize ? String::checkPlain($comment->getHostname()) : $comment->getHostname(); break; case 'name': @@ -149,7 +151,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = case 'mail': $mail = $comment->getAuthorEmail(); - $replacements[$original] = $sanitize ? check_plain($mail) : $mail; + $replacements[$original] = $sanitize ? String::checkPlain($mail) : $mail; break; case 'homepage': diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php index 7f58b18..4534076 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/argument/UserUid.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Plugin\views\argument; +use Drupal\Component\Utility\String; use Drupal\Core\Database\Connection; use Drupal\views\Plugin\views\argument\ArgumentPluginBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -64,7 +65,7 @@ function title() { return t('No user'); } - return check_plain($title); + return String::checkPlain($title); } protected function defaultActions($which = NULL) { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 081775f..3134406 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -7,6 +7,7 @@ namespace Drupal\comment\Tests; +use Drupal\Component\Utility\String; use Drupal\Core\Language\Language; /** @@ -53,10 +54,10 @@ function testCommentTokenReplacement() { // Generate and test sanitized tokens. $tests = array(); $tests['[comment:cid]'] = $comment->id(); - $tests['[comment:hostname]'] = check_plain($comment->getHostname()); + $tests['[comment:hostname]'] = String::checkPlain($comment->getHostname()); $tests['[comment:name]'] = filter_xss($comment->getAuthorName()); $tests['[comment:author]'] = filter_xss($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:title]'] = filter_xss($comment->getSubject()); $tests['[comment:body]'] = $comment->comment_body->processed; @@ -65,11 +66,11 @@ function testCommentTokenReplacement() { $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: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:title]'] = check_plain($node->getTitle()); + $tests['[comment:node:title]'] = String::checkPlain($node->getTitle()); $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. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php index f2eb699..4b320cc 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php @@ -8,6 +8,7 @@ namespace Drupal\entity_reference; use Drupal\Component\Utility\String; +use Drupal\Component\Utility\String as StringUtil; use Drupal\Core\Field\ConfigFieldItemInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; @@ -184,7 +185,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { // entity type specific plugins (e.g. 'default_node', 'default_user', // ...). if (in_array($plugin_id, $handler_groups)) { - $handlers_options[$plugin_id] = check_plain($plugin['label']); + $handlers_options[$plugin_id] = StringUtil::checkPlain($plugin['label']); } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php index 6df0d11..41a8995 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php @@ -7,6 +7,7 @@ namespace Drupal\entity_reference\Plugin\Field\FieldFormatter; +use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldItemListInterface; /** @@ -35,7 +36,7 @@ public function viewElements(FieldItemListInterface $items) { continue; } if (!empty($item->entity) && !empty($item->target_id)) { - $elements[$delta] = array('#markup' => check_plain($item->target_id)); + $elements[$delta] = array('#markup' => String::checkPlain($item->target_id)); } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index ea13e17..7b0b0ef 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -7,6 +7,7 @@ namespace Drupal\entity_reference\Plugin\Field\FieldFormatter; +use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldItemListInterface; /** @@ -74,7 +75,7 @@ public function viewElements(FieldItemListInterface $items) { ); } else { - $elements[$delta] = array('#markup' => check_plain($label)); + $elements[$delta] = array('#markup' => String::checkPlain($label)); } } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php index f7b74e4..97b5973 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/entity_reference/selection/SelectionBase.php @@ -7,11 +7,12 @@ namespace Drupal\entity_reference\Plugin\entity_reference\selection; +use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Component\Utility\NestedArray; use Drupal\entity_reference\Plugin\Type\Selection\SelectionInterface; /** @@ -174,7 +175,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA $entities = entity_load_multiple($target_type, $result); foreach ($entities as $entity_id => $entity) { $bundle = $entity->bundle(); - $options[$bundle][$entity_id] = check_plain($entity->label()); + $options[$bundle][$entity_id] = String::checkPlain($entity->label()); } return $options; diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php index 987919d..5b78296 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAutocompleteTest.php @@ -7,10 +7,10 @@ namespace Drupal\entity_reference\Tests; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Tags; use Drupal\entity_reference\EntityReferenceController; use Drupal\system\Tests\Entity\EntityUnitTestBase; - use Symfony\Component\HttpFoundation\Request; /** @@ -80,8 +80,8 @@ function testEntityReferenceAutocompletion() { // We should get both entities in a JSON encoded string. $input = '10/'; $data = $this->getAutocompleteResult('single', $input); - $this->assertIdentical($data[0]['label'], check_plain($entity_1->name->value), 'Autocomplete returned the first matching entity'); - $this->assertIdentical($data[1]['label'], check_plain($entity_2->name->value), 'Autocomplete returned the second matching entity'); + $this->assertIdentical($data[0]['label'], String::checkPlain($entity_1->name->value), 'Autocomplete returned the first matching entity'); + $this->assertIdentical($data[1]['label'], String::checkPlain($entity_2->name->value), 'Autocomplete returned the second matching entity'); // Try to autocomplete a entity label that matches the first entity. // We should only get the first entity in a JSON encoded string. @@ -89,7 +89,7 @@ function testEntityReferenceAutocompletion() { $data = $this->getAutocompleteResult('single', $input); $target = array( 'value' => $entity_1->name->value . ' (1)', - 'label' => check_plain($entity_1->name->value), + 'label' => String::checkPlain($entity_1->name->value), ); $this->assertIdentical(reset($data), $target, 'Autocomplete returns only the expected matching entity.'); @@ -97,7 +97,7 @@ function testEntityReferenceAutocompletion() { // the first entity is already typed in the autocomplete (tags) widget. $input = $entity_1->name->value . ' (1), 10/17'; $data = $this->getAutocompleteResult('tags', $input); - $this->assertIdentical($data[0]['label'], check_plain($entity_2->name->value), 'Autocomplete returned the second matching entity'); + $this->assertIdentical($data[0]['label'], String::checkPlain($entity_2->name->value), 'Autocomplete returned the second matching entity'); // Try to autocomplete a entity label with both a comma and a slash. $input = '"label with, and / t'; @@ -107,7 +107,7 @@ function testEntityReferenceAutocompletion() { $n = Tags::encode($n); $target = array( 'value' => $n, - 'label' => check_plain($entity_3->name->value), + 'label' => String::checkPlain($entity_3->name->value), ); $this->assertIdentical(reset($data), $target, 'Autocomplete returns an entity label containing a comma and a slash.'); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php index 0178a25..daf7915 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php @@ -7,6 +7,7 @@ namespace Drupal\entity_reference\Tests; +use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Language\Language; use Drupal\comment\CommentInterface; @@ -115,7 +116,7 @@ public function testNodeHandler() { $node = entity_create('node', $values); $node->save(); $nodes[$key] = $node; - $node_labels[$key] = check_plain($node->label()); + $node_labels[$key] = String::checkPlain($node->label()); } // Test as a non-admin. @@ -262,7 +263,7 @@ public function testUserHandler() { $account = $values; } $users[$key] = $account; - $user_labels[$key] = check_plain($account->getUsername()); + $user_labels[$key] = String::checkPlain($account->getUsername()); } // Test as a non-admin. @@ -442,7 +443,7 @@ public function testCommentHandler() { $comment = entity_create('comment', $values); $comment->save(); $comments[$key] = $comment; - $comment_labels[$key] = check_plain($comment->label()); + $comment_labels[$key] = String::checkPlain($comment->label()); } // Test as a non-admin. diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php index 43fd7ee..d30777b 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionSortTest.php @@ -7,6 +7,7 @@ namespace Drupal\entity_reference\Tests; +use Drupal\Component\Utility\String; use Drupal\simpletest\WebTestBase; /** @@ -115,7 +116,7 @@ public function testSort() { $node = entity_create('node', $values); $node->save(); $nodes[$key] = $node; - $node_labels[$key] = check_plain($node->label()); + $node_labels[$key] = String::checkPlain($node->label()); } // Test as a non-admin. diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 58f374a..bd08b35 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\field\FieldUpdateForbiddenException; /** @@ -50,7 +51,7 @@ function hook_field_extra_fields() { foreach (node_type_get_types() as $bundle) { if ($bundle->has_title) { $extra['node'][$bundle->type]['form']['title'] = array( - 'label' => check_plain($bundle->title_label), + 'label' => String::checkPlain($bundle->title_label), 'description' => $description, 'weight' => -5, ); diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 0c775c8..17cf875 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -5,6 +5,7 @@ */ use Drupal\Component\Utility\Html; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Xss; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Template\Attribute; @@ -506,7 +507,7 @@ function template_preprocess_field(&$variables, $hook) { // label, it needs to supply a preprocess function that sets it to the // sanitized element title or whatever else is wanted in its place. $variables['label_hidden'] = ($element['#label_display'] == 'hidden'); - $variables['label'] = check_plain($element['#title']); + $variables['label'] = String::checkPlain($element['#title']); // We want other preprocess functions and the theme implementation to have // fast access to the field item render arrays. The item render array keys diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/argument/FieldList.php b/core/modules/field/lib/Drupal/field/Plugin/views/argument/FieldList.php index d29319d..4b780f6 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/argument/FieldList.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/argument/FieldList.php @@ -7,9 +7,10 @@ namespace Drupal\field\Plugin\views\argument; -use Drupal\views\ViewExecutable; -use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Drupal\Component\Utility\String; use Drupal\views\Plugin\views\argument\Numeric; +use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Drupal\views\ViewExecutable; /** * Argument handler for list field to show the human readable name in the @@ -68,7 +69,7 @@ public function summaryName($data) { } // else fallback to the key. else { - return check_plain($value); + return String::checkPlain($value); } } diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/argument/ListString.php b/core/modules/field/lib/Drupal/field/Plugin/views/argument/ListString.php index cc43140..ebc6183 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/argument/ListString.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/argument/ListString.php @@ -7,9 +7,10 @@ namespace Drupal\field\Plugin\views\argument; -use Drupal\views\ViewExecutable; -use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Drupal\Component\Utility\String as StringUtil; use Drupal\views\Plugin\views\argument\String; +use Drupal\views\Plugin\views\display\DisplayPluginBase; +use Drupal\views\ViewExecutable; /** * Argument handler for list field to show the human readable name in the @@ -70,7 +71,7 @@ public function summaryName($data) { } // else fallback to the key. else { - return $this->caseTransform(check_plain($value), $this->options['case']); + return $this->caseTransform(StringUtil::checkPlain($value), $this->options['case']); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php index 5de1d0a..1a5afcd 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php @@ -7,6 +7,7 @@ namespace Drupal\field\Tests; +use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldDefinitionInterface; class FormTest extends FieldTestBase { @@ -104,7 +105,7 @@ function testFieldFormSingle() { $this->drupalGet('entity_test/add'); // 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->assertFieldByName("{$field_name}[0][value]", '', 'Widget is displayed'); $this->assertNoField("{$field_name}[1][value]", 'No extraneous widget is displayed'); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index 2ed54e8..2b6ed40 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -8,6 +8,7 @@ namespace Drupal\field_ui; use Drupal\Component\Plugin\PluginManagerBase; +use Drupal\Component\Utility\String; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -268,7 +269,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent 'defaultPlugin' => $this->getDefaultPlugin($field_definition->getType()), ), 'human_name' => array( - '#markup' => check_plain($label), + '#markup' => String::checkPlain($label), ), 'weight' => array( '#type' => 'textfield', diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index 2b03c6f..8aa4e91 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -7,12 +7,13 @@ namespace Drupal\field_ui; +use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; +use Drupal\field\Entity\FieldConfig; use Drupal\field_ui\OverviewBase; use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\field\Entity\FieldConfig; /** * Field UI field overview form. @@ -131,7 +132,7 @@ public function buildForm(array $form, array &$form_state, $entity_type_id = NUL 'id' => drupal_html_class($name), ), 'label' => array( - '#markup' => check_plain($instance->getLabel()), + '#markup' => String::checkPlain($instance->getLabel()), ), 'field_name' => array( '#markup' => $instance->getName(), diff --git a/core/modules/file/file.field.inc b/core/modules/file/file.field.inc index 8a64332..0ea3c8e 100644 --- a/core/modules/file/file.field.inc +++ b/core/modules/file/file.field.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Html; +use Drupal\Component\Utility\String; use Drupal\field\FieldInterface; /** @@ -197,7 +198,7 @@ function theme_file_upload_help($variables) { $descriptions[] = t('!size limit.', array('!size' => format_size($upload_validators['file_validate_size'][0]))); } 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'])) { diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 6a1e86a..9faed30 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -5,11 +5,12 @@ * Defines a "managed_file" Form API field and a "file" field for Field module. */ -use Drupal\file\Entity\File; use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Template\Attribute; +use Drupal\file\Entity\File; use Drupal\file\FileUsage\FileUsageInterface; // Load all Field module hooks for File. @@ -1018,15 +1019,15 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr // Essential file data case 'name': - $replacements[$original] = $sanitize ? check_plain($file->getFilename()) : $file->getFilename(); + $replacements[$original] = $sanitize ? String::checkPlain($file->getFilename()) : $file->getFilename(); break; case 'path': - $replacements[$original] = $sanitize ? check_plain($file->getFileUri()) : $file->getFileUri(); + $replacements[$original] = $sanitize ? String::checkPlain($file->getFileUri()) : $file->getFileUri(); break; case 'mime': - $replacements[$original] = $sanitize ? check_plain($file->getMimeType()) : $file->getMimeType(); + $replacements[$original] = $sanitize ? String::checkPlain($file->getMimeType()) : $file->getMimeType(); break; case 'size': @@ -1034,7 +1035,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr break; 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; // These tokens are default variations on the chained tokens handled below. @@ -1048,7 +1049,7 @@ function file_tokens($type, $tokens, array $data = array(), array $options = arr case 'owner': $name = $file->getOwner()->label(); - $replacements[$original] = $sanitize ? check_plain($name) : $name; + $replacements[$original] = $sanitize ? String::checkPlain($name) : $name; break; } } @@ -1596,7 +1597,7 @@ function theme_file_link($variables) { } else { $link_text = $variables['description']; - $options['attributes']['title'] = check_plain($file->getFilename()); + $options['attributes']['title'] = String::checkPlain($file->getFilename()); } $file_icon = array( @@ -1624,7 +1625,7 @@ function theme_file_icon($variables) { $file = $variables['file']; $icon_directory = $variables['icon_directory']; - $mime = check_plain($file->getMimeType()); + $mime = String::checkPlain($file->getMimeType()); $icon_url = file_icon_url($file, $icon_directory); return ''; } diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php index 5c976ed..51178d4 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldWidget/FileWidget.php @@ -7,10 +7,11 @@ namespace Drupal\file\Plugin\Field\FieldWidget; +use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\WidgetBase; use Drupal\Core\Field\FieldItemListInterface; -use Drupal\Component\Utility\NestedArray; +use Drupal\Core\Field\WidgetBase; use Drupal\field\Field; /** @@ -88,7 +89,7 @@ protected function formMultipleElements(FieldItemListInterface $items, array &$f break; } - $title = check_plain($this->fieldDefinition->getLabel()); + $title = String::checkPlain($this->fieldDefinition->getLabel()); $description = field_filter_xss($this->fieldDefinition->getDescription()); $elements = array(); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php index 03aedcb..b8c7784 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php @@ -7,6 +7,7 @@ namespace Drupal\file\Tests; +use Drupal\Component\Utility\String; use Drupal\Core\Language\Language; /** @@ -48,16 +49,16 @@ function testFileTokenReplacement() { // Generate and test sanitized tokens. $tests = array(); $tests['[file:fid]'] = $file->id(); - $tests['[file:name]'] = check_plain($file->getFilename()); - $tests['[file:path]'] = check_plain($file->getFileUri()); - $tests['[file:mime]'] = check_plain($file->getMimeType()); + $tests['[file:name]'] = String::checkPlain($file->getFilename()); + $tests['[file:path]'] = String::checkPlain($file->getFileUri()); + $tests['[file:mime]'] = String::checkPlain($file->getMimeType()); $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: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: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(); // Test to make sure that we generated something for each token. diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index e9c04d4..ab24ce1 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Html; +use Drupal\Component\Utility\String as StringUtil; use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Language\Language; @@ -939,8 +940,8 @@ function _filter_url_parse_full_links($match) { $i = 1; $match[$i] = decode_entities($match[$i]); - $caption = check_plain(_filter_url_trim($match[$i])); - $match[$i] = check_plain($match[$i]); + $caption = StringUtil::checkPlain(_filter_url_trim($match[$i])); + $match[$i] = StringUtil::checkPlain($match[$i]); return '' . $caption . ''; } @@ -954,8 +955,8 @@ function _filter_url_parse_email_links($match) { $i = 0; $match[$i] = decode_entities($match[$i]); - $caption = check_plain(_filter_url_trim($match[$i])); - $match[$i] = check_plain($match[$i]); + $caption = StringUtil::checkPlain(_filter_url_trim($match[$i])); + $match[$i] = StringUtil::checkPlain($match[$i]); return '' . $caption . ''; } @@ -969,8 +970,8 @@ function _filter_url_parse_partial_links($match) { $i = 1; $match[$i] = decode_entities($match[$i]); - $caption = check_plain(_filter_url_trim($match[$i])); - $match[$i] = check_plain($match[$i]); + $caption = StringUtil::checkPlain(_filter_url_trim($match[$i])); + $match[$i] = StringUtil::checkPlain($match[$i]); return '' . $caption . ''; } @@ -1102,7 +1103,7 @@ function _filter_autop($text) { * Escapes all HTML tags, so they will be visible instead of being effective. */ function _filter_html_escape($text) { - return trim(check_plain($text)); + return trim(StringUtil::checkPlain($text)); } /** diff --git a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php index a49f5f4..f0a7ec8 100644 --- a/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php +++ b/core/modules/filter/lib/Drupal/filter/Plugin/Filter/FilterHtml.php @@ -7,6 +7,7 @@ namespace Drupal\filter\Plugin\Filter; +use Drupal\Component\Utility\String; use Drupal\filter\Plugin\FilterBase; /** @@ -99,7 +100,7 @@ public function tips($long = FALSE) { $output .= '
' . t('This site allows HTML content. While learning all of HTML may feel intimidating, learning how to use a very small number of the most basic HTML "tags" is very easy. This table provides examples for each tag that is enabled on this site.') . '
'; $output .= '' . t('For more information see W3C\'s HTML Specifications or use your favorite search engine to find other sites that explain HTML.', array('@html-specifications' => 'http://www.w3.org/TR/html/')) . '
'; $tips = array( - 'a' => array(t('Anchors are used to make links to other pages.'), '' . check_plain(\Drupal::config('system.site')->get('name')) . ''), + 'a' => array(t('Anchors are used to make links to other pages.'), '' . String::checkPlain(\Drupal::config('system.site')->get('name')) . ''), 'br' => array(t('By default line break tags are automatically added, so use this tag to add additional ones. Use of this tag is different because it is not used with an open/close pair like all the others. Use the extra " /" inside the tag to maintain XHTML 1.0 compatibility'), t('Text with' . t('Paragraph one.') . '
' . t('Paragraph two.') . '
'), 'strong' => array(t('Strong', array(), array('context' => 'Font weight')), '' . t('Strong', array(), array('context' => 'Font weight')) . ''), @@ -141,7 +142,7 @@ public function tips($long = FALSE) { if (!empty($tips[$tag])) { $rows[] = array( array('data' => $tips[$tag][0], 'class' => array('description')), - array('data' => '' . check_plain($tips[$tag][1]) . '
', 'class' => array('type')),
+ array('data' => '' . String::checkPlain($tips[$tag][1]) . '
', 'class' => array('type')),
array('data' => $tips[$tag][1], 'class' => array('get'))
);
}
@@ -172,7 +173,7 @@ public function tips($long = FALSE) {
foreach ($entities as $entity) {
$rows[] = array(
array('data' => $entity[0], 'class' => array('description')),
- array('data' => '' . check_plain($entity[1]) . '
', 'class' => array('type')),
+ array('data' => '' . String::checkPlain($entity[1]) . '
', 'class' => array('type')),
array('data' => $entity[1], 'class' => array('get'))
);
}
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index e10c5ca..8d13d86 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests;
+use Drupal\Component\Utility\String;
use Drupal\simpletest\WebTestBase;
/**
@@ -254,7 +255,7 @@ function testFilterAdmin() {
$edit['body[0][format]'] = $plain;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalGet('node/' . $node->id());
- $this->assertText(check_plain($text), 'The "Plain text" text format escapes all HTML tags.');
+ $this->assertText(String::checkPlain($text), 'The "Plain text" text format escapes all HTML tags.');
\Drupal::config('filter.settings')
->set('always_show_fallback_choice', FALSE)
->save();
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
index a51d6b9..ee92929 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
@@ -8,8 +8,9 @@
namespace Drupal\filter\Tests;
use Drupal\Component\Utility\Html;
-use Drupal\simpletest\DrupalUnitTestBase;
+use Drupal\Component\Utility\String;
use Drupal\filter\FilterBag;
+use Drupal\simpletest\DrupalUnitTestBase;
/**
* Unit tests for core filters.
@@ -692,10 +693,10 @@ function assertFilteredString($filter, $tests) {
)));
}
if (!$success) {
- $this->verbose('Source:' . check_plain(var_export($source, TRUE)) . '' - . '
' . check_plain(var_export($result, TRUE)) . '' + $this->verbose('Source:
' . String::checkPlain(var_export($source, TRUE)) . '' + . '
' . String::checkPlain(var_export($result, TRUE)) . '' . '
' . check_plain(var_export($value, TRUE)) . '' + . '
' . String::checkPlain(var_export($value, TRUE)) . '' ); } } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 1e9e7ff..aa99f62 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -7,16 +7,17 @@ namespace Drupal\node\Plugin\Search; +use Drupal\Component\Utility\String; +use Drupal\Core\Access\AccessibleInterface; use Drupal\Core\Config\Config; use Drupal\Core\Database\Connection; +use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\Query\SelectExtender; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\KeyValueStore\StateInterface; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; -use Drupal\Core\Access\AccessibleInterface; -use Drupal\Core\Database\Query\Condition; use Drupal\node\NodeInterface; use Drupal\search\Plugin\ConfigurableSearchPluginBase; use Drupal\search\Plugin\SearchIndexingInterface; @@ -254,7 +255,7 @@ public function execute() { ); $results[] = array( 'link' => $node->url('canonical', array('absolute' => TRUE, 'language' => $language)), - 'type' => check_plain($this->entityManager->getStorageController('node_type')->load($node->bundle())->label()), + 'type' => String::checkPlain($this->entityManager->getStorageController('node_type')->load($node->bundle())->label()), 'title' => $node->label(), 'user' => drupal_render($username), 'date' => $node->getChangedTime(), @@ -339,7 +340,7 @@ protected function indexNode(NodeInterface $node) { unset($build['#theme']); $node->rendered = drupal_render($build); - $text = '
'; - $build['#markup'] = check_plain($build['#markup']); + $build['#markup'] = String::checkPlain($build['#markup']); $build['#suffix'] = ''; } diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php index 5903780..646f2ac 100644 --- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php @@ -7,6 +7,7 @@ namespace Drupal\rest\Tests\Views; +use Drupal\Component\Utility\String; use Drupal\views\Tests\Plugin\PluginTestBase; use Drupal\views\Tests\ViewTestData; @@ -279,7 +280,7 @@ public function testPreview() { $entities[] = $row->_entity; } - $expected = check_plain($serializer->serialize($entities, 'json')); + $expected = String::checkPlain($serializer->serialize($entities, 'json')); $view->display_handler->setContentType('json'); $view->live_preview = TRUE; diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index e3977cb..702577b 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -7,6 +7,7 @@ namespace Drupal\search\Tests; +use Drupal\Component\Utility\String; use Drupal\field\Field; /** @@ -110,7 +111,7 @@ function testSearchResultsComment() { // Verify that comment is rendered using proper format. $this->assertText($comment_body, 'Comment body text found in search results.'); $this->assertNoRaw(t('n/a'), 'HTML in comment body is not hidden.'); - $this->assertNoRaw(check_plain($edit_comment['comment_body[0][value]']), 'HTML in comment body is not escaped.'); + $this->assertNoRaw(String::checkPlain($edit_comment['comment_body[0][value]']), 'HTML in comment body is not escaped.'); // Hide comments. $this->drupalLogin($this->admin_user); diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 600dc83..bb154b2 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -5,6 +5,7 @@ * Enables site-wide keyword searching. */ +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; /** @@ -719,7 +720,7 @@ function search_excerpt($keys, $text, $langcode = NULL) { // We didn't find any keyword matches, so just return the first part of the // text. We also need to re-encode any HTML special characters that we // entity-decoded above. - return check_plain(truncate_utf8($text, 256, TRUE, TRUE)); + return String::checkPlain(truncate_utf8($text, 256, TRUE, TRUE)); } // Sort the text ranges by starting position. @@ -760,7 +761,7 @@ function search_excerpt($keys, $text, $langcode = NULL) { // translated. Let translators have the ... separator text as one chunk. $dots = explode('!excerpt', t('... !excerpt ... !excerpt ...')); $text = (isset($new_ranges[0]) ? '' : $dots[0]) . implode($dots[1], $out) . (($max_end < strlen($text) - 1) ? $dots[2] : ''); - $text = check_plain($text); + $text = String::checkPlain($text); // Highlight keywords. Must be done at once to prevent conflicts ('strong' // and ''). diff --git a/core/modules/search/search.pages.inc b/core/modules/search/search.pages.inc index ec71855..9fe5efb 100644 --- a/core/modules/search/search.pages.inc +++ b/core/modules/search/search.pages.inc @@ -5,6 +5,7 @@ * User page callbacks for the Search module. */ +use Drupal\Component\Utility\String; use Drupal\Core\Language\Language; /** @@ -35,7 +36,7 @@ function template_preprocess_search_result(&$variables) { $result = $variables['result']; $variables['url'] = check_url($result['link']); - $variables['title'] = check_plain($result['title']); + $variables['title'] = String::checkPlain($result['title']); if (isset($result['language']) && $result['language'] != $language_interface->id && $result['language'] != Language::LANGCODE_NOT_SPECIFIED) { $variables['title_attributes']['lang'] = $result['language']; $variables['content_attributes']['lang'] = $result['language']; @@ -43,7 +44,7 @@ function template_preprocess_search_result(&$variables) { $info = array(); if (!empty($result['plugin_id'])) { - $info['plugin_id'] = check_plain($result['plugin_id']); + $info['plugin_id'] = String::checkPlain($result['plugin_id']); } if (!empty($result['user'])) { $info['user'] = $result['user']; diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index 8e8b721..74d8486 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -5,6 +5,8 @@ * Administrative page callbacks for the shortcut module. */ +use Drupal\Component\Utility\String; + /** * Form callback: builds the form for switching shortcut sets. * @@ -39,7 +41,7 @@ function shortcut_set_switch($form, &$form_state, $account = NULL) { $options = array(); foreach ($sets as $name => $set) { - $options[$name] = check_plain($set->label()); + $options[$name] = String::checkPlain($set->label()); } // Only administrators can add shortcut sets. diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index ccefb31..e899a92 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -9,15 +9,16 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\String as StringUtil; use Drupal\Component\Utility\String; -use Drupal\Core\DrupalKernel; -use Drupal\Core\Database\Database; use Drupal\Core\Database\ConnectionNotDefinedException; +use Drupal\Core\Database\Database; +use Drupal\Core\Datetime\DrupalDateTime; +use Drupal\Core\DrupalKernel; use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\UserSession; use Drupal\Core\StreamWrapper\PublicStream; -use Drupal\Core\Datetime\DrupalDateTime; use Drupal\block\Entity\Block; use Symfony\Component\HttpFoundation\Request; @@ -1402,7 +1403,7 @@ protected function drupalGet($path, array $options = array(), array $headers = a $verbose = 'GET request to: ' . $path . '
' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . ''; + $verbose .= '
' . StringUtil::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . ''; } $verbose .= '
' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . ''; + $verbose .= '
' . StringUtil::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . ''; } $verbose .= '
' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . ''); + '
' . StringUtil::checkPlain(var_export(array_map('trim', $this->headers), TRUE)) . ''); } return $out; @@ -2995,9 +2996,9 @@ protected function assertNoTitle($title, $message = '', $group = 'Other') { */ protected function assertThemeOutput($callback, array $variables = array(), $expected, $message = '', $group = 'Other') { $output = _theme($callback, $variables); - $this->verbose('Variables:' . '
' . check_plain(var_export($variables, TRUE)) . '' - . '
' . check_plain(var_export($output, TRUE)) . '' - . '
' . check_plain(var_export($expected, TRUE)) . '' + $this->verbose('Variables:' . '
' . StringUtil::checkPlain(var_export($variables, TRUE)) . '' + . '
' . StringUtil::checkPlain(var_export($output, TRUE)) . '' + . '
' . StringUtil::checkPlain(var_export($expected, TRUE)) . '' . '
./' . check_plain($site_directory) . '
',
+ '!sites-simpletest' => './' . String::checkPlain($site_directory) . '
',
)),
);
}
@@ -75,7 +77,7 @@ function simpletest_requirements($phase) {
'value' => t('Not protected'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The file !file does not exist and could not be created automatically, which poses a security risk. Ensure that the directory is writable.', array(
- '!file' => './' . check_plain($site_directory) . '/.htaccess
',
+ '!file' => './' . String::checkPlain($site_directory) . '/.htaccess
',
)),
);
}
diff --git a/core/modules/system/form.api.php b/core/modules/system/form.api.php
index 5ae2d69..33d2b11 100644
--- a/core/modules/system/form.api.php
+++ b/core/modules/system/form.api.php
@@ -5,6 +5,8 @@
* Calbacks provided by the form system.
*/
+use Drupal\Component\Utility\String;
+
/**
* @addtogroup callbacks
* @{
@@ -74,7 +76,7 @@ function callback_batch_operation($MULTIPLE_PARAMS, &$context) {
node_save($node);
// Store some result for post-processing in the finished callback.
- $context['results'][] = check_plain($node->title);
+ $context['results'][] = String::checkPlain($node->title);
// Update our progress information.
$context['sandbox']['progress']++;
diff --git a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php
index 2d51684..56e779d 100644
--- a/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/FileSystemForm.php
@@ -7,8 +7,9 @@
namespace Drupal\system\Form;
-use Drupal\Core\StreamWrapper\PublicStream;
+use Drupal\Component\Utility\String;
use Drupal\Core\Form\ConfigFormBase;
+use Drupal\Core\StreamWrapper\PublicStream;
/**
* Configure file system settings for this site.
@@ -55,7 +56,7 @@ public function buildForm(array $form, array &$form_state) {
// Any visible, writeable wrapper can potentially be used for the files
// directory, including a remote file system that integrates with a CDN.
foreach (file_get_stream_wrappers(STREAM_WRAPPERS_WRITE_VISIBLE) as $scheme => $info) {
- $options[$scheme] = check_plain($info['description']);
+ $options[$scheme] = String::checkPlain($info['description']);
}
if (!empty($options)) {
diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
index a090c67..5a88e31 100644
--- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
+++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php
@@ -7,12 +7,13 @@
namespace Drupal\system\Form;
+use Drupal\Component\Utility\String;
use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Access\AccessManager;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\KeyValueStore\KeyValueStoreExpirableInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
-use Drupal\Core\Access\AccessManager;
/**
* Provides module installation interface.
@@ -77,7 +78,7 @@ public function getFormId() {
*/
public function buildForm(array $form, array &$form_state) {
require_once DRUPAL_ROOT . '/core/includes/install.inc';
- $distribution = check_plain(drupal_install_profile_distribution_name());
+ $distribution = String::checkPlain(drupal_install_profile_distribution_name());
// Include system.admin.inc so we can use the sort callbacks.
$this->moduleHandler->loadInclude('system', 'inc', 'system.admin');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
index 5c016ce..536868f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/CascadingStylesheetsTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Common;
+use Drupal\Component\Utility\String;
use Drupal\Core\Language\Language;
use Drupal\simpletest\DrupalUnitTestBase;
@@ -79,7 +80,7 @@ function testRenderFile() {
$this->assertTrue(strpos($styles, $css) > 0, 'Rendered CSS includes the added stylesheet.');
// Verify that newlines are properly added inside style tags.
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
- $css_processed = '';
+ $css_processed = '';
$this->assertEqual(trim($styles), $css_processed, 'Rendered CSS includes newlines inside style tags for JavaScript use.');
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderWebTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderWebTest.php
index c42997d..3b7b857 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderWebTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderWebTest.php
@@ -7,6 +7,7 @@
namespace Drupal\system\Tests\Common;
+use Drupal\Component\Utility\String;
use Drupal\simpletest\WebTestBase;
/**
@@ -151,8 +152,8 @@ function testDrupalRenderFormElements() {
protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
$original_element = $element;
$this->drupalSetContent(drupal_render($element));
- $this->verbose('' . check_plain(var_export($original_element, TRUE)) . '' - . '
' . check_plain(var_export($element, TRUE)) . '' + $this->verbose('
' . String::checkPlain(var_export($original_element, TRUE)) . '' + . '
' . String::checkPlain(var_export($element, TRUE)) . '' . '
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Simple table headers sorted correctly.'); // Test with simple table headers plus $_GET parameters that should _not_ @@ -56,7 +57,7 @@ function testTableSortInit() { )); \Drupal::getContainer()->set('request', $request); $ts = tablesort_init($headers); - $this->verbose(strtr('$ts:
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Simple table headers plus non-overriding $_GET parameters sorted correctly.'); // Test with simple table headers plus $_GET parameters that _should_ @@ -72,7 +73,7 @@ function testTableSortInit() { $expected_ts['sort'] = 'desc'; $expected_ts['query'] = array('alpha' => 'beta'); $ts = tablesort_init($headers); - $this->verbose(strtr('$ts:
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Simple table headers plus $_GET parameters sorted correctly.'); // Test complex table headers. @@ -104,7 +105,7 @@ function testTableSortInit() { 'sort' => 'desc', 'query' => array(), ); - $this->verbose(strtr('$ts:
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Complex table headers sorted correctly.'); // Test complex table headers plus $_GET parameters that should _not_ @@ -123,7 +124,7 @@ function testTableSortInit() { 'sort' => 'asc', 'query' => array(), ); - $this->verbose(strtr('$ts:
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus non-overriding $_GET parameters sorted correctly.'); // Test complex table headers plus $_GET parameters that _should_ @@ -144,7 +145,7 @@ function testTableSortInit() { 'query' => array('alpha' => 'beta'), ); $ts = tablesort_init($headers); - $this->verbose(strtr('$ts:
!ts', array('!ts' => check_plain(var_export($ts, TRUE))))); + $this->verbose(strtr('$ts:
!ts', array('!ts' => String::checkPlain(var_export($ts, TRUE))))); $this->assertEqual($ts, $expected_ts, 'Complex table headers plus $_GET parameters sorted correctly.'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php index c261031..53f5cec 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php @@ -8,6 +8,7 @@ namespace Drupal\system\Tests\Form; use Drupal\Component\Utility\String; +use Drupal\Component\Utility\String as StringUtil; use Drupal\simpletest\WebTestBase; class FormTest extends WebTestBase { @@ -606,7 +607,7 @@ function testDisabledMarkup() { $path = strtr($path, array('!type' => $type)); // Verify that the element exists. $element = $this->xpath($path, array( - ':name' => check_plain($name), + ':name' => StringUtil::checkPlain($name), ':div-class' => $class, ':value' => isset($item['#value']) ? $item['#value'] : '', )); diff --git a/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php b/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php index 751bf0c..cf4524c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Mail; +use Drupal\Component\Utility\String; use Drupal\simpletest\WebTestBase; /** @@ -36,7 +37,7 @@ protected function stringToHtml($text) { str_replace( array("\n", ' '), array('\n', ' '), - check_plain($text) + String::checkPlain($text) ) . '"'; } @@ -58,7 +59,7 @@ protected function assertHtmlToText($html, $text, $message, $allowed_tags = NULL $tested_tags = implode(', ', array_unique($matches[1])); $message .= ' (' . $tested_tags . ')'; $result = drupal_html_to_text($html, $allowed_tags); - $pass = $this->assertEqual($result, $text, check_plain($message)); + $pass = $this->assertEqual($result, $text, String::checkPlain($message)); $verbose = 'html =
' . $this->stringToHtml($html) . '
' . $this->stringToHtml($result) . '
' . $this->stringToHtml($text) diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index d7e51c4..6df5800 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Menu; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; /** @@ -271,7 +272,7 @@ function testBreadCrumbs() { $link['link_path'] => $link['link_title'], ); $this->assertBreadcrumb($link['link_path'], $trail, $term->label(), $tree); - $this->assertRaw(check_plain($parent->getTitle()), 'Tagged node found.'); + $this->assertRaw(String::checkPlain($parent->getTitle()), 'Tagged node found.'); // Additionally make sure that this link appears only once; i.e., the // untranslated menu links automatically generated from menu router items diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php index 4dd3e1a..490b7d4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Menu; +use Drupal\Component\Utility\String; use Drupal\simpletest\WebTestBase; /** @@ -120,7 +121,7 @@ protected function doTestDescriptionMenuItems() { // Verify that the menu router item title is output as page title. $this->drupalGet('menu_callback_description'); $this->assertText(t('Menu item description text')); - $this->assertRaw(check_plain('Menu item description arguments')); + $this->assertRaw(String::checkPlain('Menu item description arguments')); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuTestBase.php index d205b13..fc896d8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/MenuTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/MenuTestBase.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Menu; +use Drupal\Component\Utility\String; use Drupal\simpletest\WebTestBase; abstract class MenuTestBase extends WebTestBase { @@ -65,7 +66,7 @@ protected function assertBreadcrumbParts($trail) { foreach ($trail as $path => $title) { $url = url($path); $part = array_shift($parts); - $pass = ($pass && $part['href'] === $url && $part['text'] === check_plain($title)); + $pass = ($pass && $part['href'] === $url && $part['text'] === String::checkPlain($title)); } } // No parts must be left, or an expected "Home" will always pass. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleTest.php index 33f2f47..f3e3e5e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\System; +use Drupal\Component\Utility\String; use Drupal\Core\Utility\Title; use Drupal\simpletest\WebTestBase; @@ -80,7 +81,7 @@ function testTitleTags() { $node = $this->drupalGetNodeByTitle($edit['title[0][value]']); $this->assertNotNull($node, 'Node created and found in database'); $this->drupalGet("node/" . $node->id()); - $this->assertText(check_plain($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.'); + $this->assertText(String::checkPlain($edit['title[0][value]']), 'Check to make sure tags in the node title are converted.'); } /** * Test if the title of the site is XSS proof. @@ -88,7 +89,7 @@ function testTitleTags() { function testTitleXSS() { // Set some title with JavaScript and HTML chars to escape. $title = ' & < > " \' '; - $title_filtered = check_plain($title); + $title_filtered = String::checkPlain($title); $slogan = ''; $slogan_filtered = filter_xss_admin($slogan); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php index 586e1eb..d01f68e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/FunctionsTest.php @@ -7,6 +7,7 @@ namespace Drupal\system\Tests\Theme; +use Drupal\Component\Utility\String; use Drupal\Core\Session\UserSession; use Drupal\simpletest\WebTestBase; use Symfony\Cmf\Component\Routing\RouteObjectInterface; @@ -198,10 +199,10 @@ function testLinks() { $expected_links = ''; $expected_links .= '
' . filter_xss_admin($this->token->replace($this->getBody())) . '
'; return array('#markup' => $output); } diff --git a/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Plugin/tour/tip/TipPluginImage.php b/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Plugin/tour/tip/TipPluginImage.php index 79ed03c..89f051a 100644 --- a/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Plugin/tour/tip/TipPluginImage.php +++ b/core/modules/tour/tests/tour_test/lib/Drupal/tour_test/Plugin/tour/tip/TipPluginImage.php @@ -7,6 +7,7 @@ namespace Drupal\tour_test\Plugin\tour\tip; +use Drupal\Component\Utility\String; use Drupal\tour\TipPluginBase; /** @@ -44,7 +45,7 @@ public function getOutput() { '#uri' => $this->get('url'), '#alt' => $this->get('alt'), ); - $output = '' . drupal_render($image) . '
'; return array('#markup' => $output); } diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index e94c163..6c794d0 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -5,6 +5,8 @@ * User page callbacks for tracker.module. */ +use Drupal\Component\Utility\String; + /** * Page callback: Generates a page of tracked nodes for the site. @@ -86,7 +88,7 @@ function tracker_page($account = NULL) { ); $row = array( - 'type' => check_plain(node_get_type_label($node)), + 'type' => String::checkPlain(node_get_type_label($node)), 'title' => array('data' => l($node->getTitle(), 'node/' . $node->id()) . ' ' . drupal_render($mark_build)), 'author' => array('data' => array('#theme' => 'username', '#account' => $node->getOwner())), 'replies' => array('class' => array('replies'), 'data' => $comments), diff --git a/core/modules/update/update.manager.inc b/core/modules/update/update.manager.inc index b0d0483..44c4684 100644 --- a/core/modules/update/update.manager.inc +++ b/core/modules/update/update.manager.inc @@ -36,8 +36,9 @@ * root. */ -use Drupal\Core\Updater\Updater; +use Drupal\Component\Utility\String; use Drupal\Core\FileTransfer\Local; +use Drupal\Core\Updater\Updater; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -108,14 +109,14 @@ function update_manager_update_form($form, $form_state = array(), $context) { $project_name = l($project['title'], $project['link']); } else { - $project_name = check_plain($project['title']); + $project_name = String::checkPlain($project['title']); } } elseif (!empty($project['info']['name'])) { - $project_name = check_plain($project['info']['name']); + $project_name = String::checkPlain($project['info']['name']); } else { - $project_name = check_plain($name); + $project_name = String::checkPlain($name); } if ($project['project_type'] == 'theme' || $project['project_type'] == 'theme-disabled') { $project_name .= ' ' . t('(Theme)'); diff --git a/core/modules/update/update.report.inc b/core/modules/update/update.report.inc index 51da7dd..579f461 100644 --- a/core/modules/update/update.report.inc +++ b/core/modules/update/update.report.inc @@ -5,6 +5,8 @@ * Code required only when rendering the available updates report. */ +use Drupal\Component\Utility\String; + /** * Returns HTML for the project status report. * @@ -83,7 +85,7 @@ function theme_update_report($variables) { $row = '