diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
index 9483170..5a03272 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
@@ -65,7 +65,7 @@ class AggregatorTestBase extends WebTestBase {
    *   A feed array.
    */
   function getFeedEditArray($feed_url = NULL) {
-    $feed_name = $this->randomName(10);
+    $feed_name = $this->randomSafeString(10);
     if (!$feed_url) {
       $feed_url = url('rss.xml', array(
         'query' => array('feed' => $feed_name),
@@ -299,8 +299,8 @@ EOF;
     // Post $count article nodes.
     for ($i = 0; $i < $count; $i++) {
       $edit = array();
-      $edit['title'] = $this->randomName();
-      $edit["body[$langcode][0][value]"] = $this->randomName();
+      $edit['title'] = $this->randomSafeString();
+      $edit["body[$langcode][0][value]"] = $this->randomSafeString();
       $this->drupalPost('node/add/article', $edit, t('Save'));
     }
   }
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php
index 5866358..5a3e4bd 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedItemTest.php
@@ -24,7 +24,7 @@ class CategorizeFeedItemTest extends AggregatorTestBase {
     $this->createSampleNodes();
 
     // Simulate form submission on "admin/config/services/aggregator/add/category".
-    $edit = array('title' => $this->randomName(10), 'description' => '');
+    $edit = array('title' => $this->randomSafeString(10), 'description' => '');
     $this->drupalPost('admin/config/services/aggregator/add/category', $edit, t('Save'));
     $this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), t('The category %title has been added.', array('%title' => $edit['title'])));
 
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedTest.php
index 2ff6316..c963517 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedTest.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/CategorizeFeedTest.php
@@ -22,11 +22,11 @@ class CategorizeFeedTest extends AggregatorTestBase {
   function testCategorizeFeed() {
 
     // Create 2 categories.
-    $category_1 = array('title' => $this->randomName(10), 'description' => '');
+    $category_1 = array('title' => $this->randomSafeString(10), 'description' => '');
     $this->drupalPost('admin/config/services/aggregator/add/category', $category_1, t('Save'));
     $this->assertRaw(t('The category %title has been added.', array('%title' => $category_1['title'])), t('The category %title has been added.', array('%title' => $category_1['title'])));
 
-    $category_2 = array('title' => $this->randomName(10), 'description' => '');
+    $category_2 = array('title' => $this->randomSafeString(10), 'description' => '');
     $this->drupalPost('admin/config/services/aggregator/add/category', $category_2, t('Save'));
     $this->assertRaw(t('The category %title has been added.', array('%title' => $category_2['title'])), t('The category %title has been added.', array('%title' => $category_2['title'])));
 
diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php
index fa79f1c..b64bc82 100644
--- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/ImportOpmlTest.php
@@ -22,7 +22,7 @@ class ImportOpmlTest extends AggregatorTestBase {
   function openImportForm() {
     db_delete('aggregator_category')->execute();
 
-    $category = $this->randomName(10);
+    $category = $this->randomSafeString(10);
     $cid = db_insert('aggregator_category')
       ->fields(array(
         'title' => $category,
@@ -85,7 +85,7 @@ class ImportOpmlTest extends AggregatorTestBase {
     db_delete('aggregator_category')->execute();
     db_delete('aggregator_category_feed')->execute();
 
-    $category = $this->randomName(10);
+    $category = $this->randomSafeString(10);
     db_insert('aggregator_category')
       ->fields(array(
         'cid' => 1,
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
index e9a1603..4fb8675 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockCacheTest.php
@@ -52,7 +52,7 @@ class BlockCacheTest extends WebTestBase {
     $this->setCacheMode(DRUPAL_CACHE_PER_ROLE);
 
     // Enable our test block. Set some content for it to display.
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
     $this->drupalLogin($this->normal_user);
     $this->drupalGet('');
@@ -60,7 +60,7 @@ class BlockCacheTest extends WebTestBase {
 
     // Change the content, but the cached copy should still be served.
     $old_content = $current_content;
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
     $this->drupalGet('');
     $this->assertText($old_content, t('Block is served from the cache.'));
@@ -73,7 +73,7 @@ class BlockCacheTest extends WebTestBase {
 
     // Test whether the cached data is served for the correct users.
     $old_content = $current_content;
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
     $this->drupalLogout();
     $this->drupalGet('');
@@ -97,14 +97,14 @@ class BlockCacheTest extends WebTestBase {
    */
   function testCacheGlobal() {
     $this->setCacheMode(DRUPAL_CACHE_GLOBAL);
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     $this->drupalGet('');
     $this->assertText($current_content, t('Block content displays.'));
 
     $old_content = $current_content;
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     $this->drupalLogout();
@@ -117,7 +117,7 @@ class BlockCacheTest extends WebTestBase {
    */
   function testNoCache() {
     $this->setCacheMode(DRUPAL_NO_CACHE);
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     // If DRUPAL_NO_CACHE has no effect, the next request would be cached.
@@ -125,7 +125,7 @@ class BlockCacheTest extends WebTestBase {
     $this->assertText($current_content, t('Block content displays.'));
 
     // A cached copy should not be served.
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
     $this->drupalGet('');
     $this->assertText($current_content, t('DRUPAL_NO_CACHE prevents blocks from being cached.'));
@@ -136,7 +136,7 @@ class BlockCacheTest extends WebTestBase {
    */
   function testCachePerUser() {
     $this->setCacheMode(DRUPAL_CACHE_PER_USER);
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
     $this->drupalLogin($this->normal_user);
 
@@ -144,7 +144,7 @@ class BlockCacheTest extends WebTestBase {
     $this->assertText($current_content, t('Block content displays.'));
 
     $old_content = $current_content;
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     $this->drupalGet('');
@@ -164,14 +164,14 @@ class BlockCacheTest extends WebTestBase {
    */
   function testCachePerPage() {
     $this->setCacheMode(DRUPAL_CACHE_PER_PAGE);
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     $this->drupalGet('node');
     $this->assertText($current_content, t('Block content displays on the node page.'));
 
     $old_content = $current_content;
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
 
     $this->drupalGet('user');
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
index c0891ac..22b5285 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockHtmlIdTest.php
@@ -34,7 +34,7 @@ class BlockHtmlIdTest extends WebTestBase {
     $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
 
     // Make sure the block has some content so it will appear
-    $current_content = $this->randomName();
+    $current_content = $this->randomSafeString();
     variable_set('block_test_content', $current_content);
   }
 
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
index 04aef2d..e7db98a 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockLanguageTest.php
@@ -47,7 +47,7 @@ class BlockLanguageTest extends WebTestBase {
     $this->assertField('langcodes[en]', t('Language visibility field is visible.'));
 
     // Create a new block.
-    $info_name = $this->randomString(10);
+    $info_name = $this->randomUnsafeString(10);
     $body = '';
     for ($i = 0; $i <= 100; $i++) {
       $body .= chr(rand(97, 122));
@@ -102,7 +102,7 @@ class BlockLanguageTest extends WebTestBase {
     $this->assertText('French', t('Language added successfully.'));
 
     // Create a new block.
-    $info_name = $this->randomString(10);
+    $info_name = $this->randomUnsafeString(10);
     $body = '';
     for ($i = 0; $i <= 100; $i++) {
       $body .= chr(rand(97, 122));
@@ -157,7 +157,7 @@ class BlockLanguageTest extends WebTestBase {
     $this->assertText('French', t('Language added successfully.'));
 
     // Create a new block.
-    $info_name = $this->randomString(10);
+    $info_name = $this->randomUnsafeString(10);
     $body = '';
     for ($i = 0; $i <= 100; $i++) {
       $body .= chr(rand(97, 122));
diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
index 38e65c4..27d51cb 100644
--- a/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
+++ b/core/modules/block/lib/Drupal/block/Tests/BlockTest.php
@@ -80,9 +80,9 @@ class BlockTest extends WebTestBase {
 
     // Add a new custom block by filling out the input form on the admin/structure/block/add page.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
-    $custom_block['title'] = $this->randomName(8);
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['info'] = $this->randomSafeString(8);
+    $custom_block['title'] = $this->randomSafeString(8);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
     // Confirm that the custom block has been created, and then query the created bid.
@@ -130,8 +130,8 @@ class BlockTest extends WebTestBase {
   function testCustomBlockFormat() {
     // Add a new custom block by filling out the input form on the admin/structure/block/add page.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
-    $custom_block['title'] = $this->randomName(8);
+    $custom_block['info'] = $this->randomSafeString(8);
+    $custom_block['title'] = $this->randomSafeString(8);
     $custom_block['body[value]'] = '<h1>Full HTML</h1>';
     $full_html_format = filter_format_load('full_html');
     $custom_block['body[format]'] = $full_html_format->format;
@@ -172,13 +172,13 @@ class BlockTest extends WebTestBase {
     $block = array();
 
     // Create a random title for the block
-    $title = $this->randomName(8);
+    $title = $this->randomSafeString(8);
 
     // Create the custom block
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
+    $custom_block['info'] = $this->randomSafeString(8);
     $custom_block['title'] = $title;
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
     $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
@@ -222,13 +222,13 @@ class BlockTest extends WebTestBase {
     $block = array();
 
     // Create a random title for the block
-    $title = $this->randomName(8);
+    $title = $this->randomSafeString(8);
 
     // Create the custom block
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
+    $custom_block['info'] = $this->randomSafeString(8);
     $custom_block['title'] = $title;
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
     $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
@@ -264,13 +264,13 @@ class BlockTest extends WebTestBase {
     $block = array();
 
     // Create a random title for the block.
-    $title = $this->randomName(8);
+    $title = $this->randomSafeString(8);
 
     // Create our custom test block.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
+    $custom_block['info'] = $this->randomSafeString(8);
     $custom_block['title'] = $title;
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
     $bid = db_query("SELECT bid FROM {block_custom} WHERE info = :info", array(':info' => $custom_block['info']))->fetchField();
@@ -316,7 +316,7 @@ class BlockTest extends WebTestBase {
     $block = array();
     $block['module'] = 'system';
     $block['delta'] = 'management';
-    $block['title'] = $this->randomName(8);
+    $block['title'] = $this->randomSafeString(8);
 
     // Set block title to confirm that interface works and override any custom titles.
     $this->drupalPost('admin/structure/block/manage/' . $block['module'] . '/' . $block['delta'] . '/configure', array('title' => $block['title']), t('Save block'));
diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php
index 9e621bb..e3aaa06 100644
--- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php
+++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php
@@ -205,8 +205,8 @@ class BookTest extends WebTestBase {
 
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
-    $edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
+    $edit["title"] = $number . ' - SimpleTest test node ' . $this->randomSafeString(10);
+    $edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomSafeString(32) . ' ' . $this->randomSafeString(32);
     $edit['book[bid]'] = $book_nid;
 
     if ($parent !== NULL) {
@@ -272,7 +272,7 @@ class BookTest extends WebTestBase {
     $this->drupalLogin($this->admin_user);
 
     // Set block title to confirm that the interface is available.
-    $block_title = $this->randomName(16);
+    $block_title = $this->randomSafeString(16);
     $this->drupalPost('admin/structure/block/manage/book/navigation/configure', array('title' => $block_title), t('Save block'));
     $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
 
@@ -304,7 +304,7 @@ class BookTest extends WebTestBase {
      $edit = array();
 
      // Set the block title.
-     $block_title = $this->randomName(16);
+     $block_title = $this->randomSafeString(16);
      $edit['title'] = $block_title;
 
      // Set block display to 'Show block only on book pages'.
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php
index 8f802c1..fedcadd 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentActionsTest.php
@@ -24,8 +24,8 @@ class CommentActionsTest extends CommentTestBase {
    */
   function testCommentPublishUnpublishActions() {
     $this->drupalLogin($this->web_user);
-    $comment_text = $this->randomName();
-    $subject = $this->randomName();
+    $comment_text = $this->randomSafeString();
+    $subject = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $subject);
     $comment = comment_load($comment->id);
 
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
index 5181e32..aac2735 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAnonymousTest.php
@@ -39,7 +39,7 @@ class CommentAnonymousTest extends CommentTestBase {
     $this->drupalLogout();
 
     // Post anonymous comment without contact info.
-    $anonymous_comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $anonymous_comment1 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
     $this->assertTrue($this->commentExists($anonymous_comment1), t('Anonymous comment without contact info found.'));
 
     // Allow contact info.
@@ -48,7 +48,7 @@ class CommentAnonymousTest extends CommentTestBase {
 
     // Attempt to edit anonymous comment.
     $this->drupalGet('comment/' . $anonymous_comment1->id . '/edit');
-    $edited_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
+    $edited_comment = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString());
     $this->assertTrue($this->commentExists($edited_comment, FALSE), t('Modified reply found.'));
     $this->drupalLogout();
 
@@ -56,16 +56,16 @@ class CommentAnonymousTest extends CommentTestBase {
     $this->drupalGet('comment/reply/' . $this->node->nid);
     $this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
 
-    $anonymous_comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $anonymous_comment2 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
     $this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.'));
 
     // Ensure anonymous users cannot post in the name of registered users.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array(
       'name' => $this->admin_user->name,
-      'mail' => $this->randomName() . '@example.com',
-      'subject' => $this->randomName(),
-      "comment_body[$langcode][0][value]" => $this->randomName(),
+      'mail' => $this->randomSafeString() . '@example.com',
+      'subject' => $this->randomSafeString(),
+      "comment_body[$langcode][0][value]" => $this->randomSafeString(),
     );
     $this->drupalPost('comment/reply/' . $this->node->nid, $edit, t('Save'));
     $this->assertText(t('The name you used belongs to a registered user.'));
@@ -79,14 +79,14 @@ class CommentAnonymousTest extends CommentTestBase {
     $this->drupalGet('comment/reply/' . $this->node->nid);
     $this->assertTrue($this->commentContactInfoAvailable(), t('Contact information available.'));
 
-    $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
+    $anonymous_comment3 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $this->assertText(t('E-mail field is required.'), t('E-mail required.')); // Name should have 'Anonymous' for value by default.
     $this->assertFalse($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) not found.'));
 
     // Post comment with contact info (required).
-    $author_name = $this->randomName();
-    $author_mail = $this->randomName() . '@example.com';
-    $anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), array('name' => $author_name, 'mail' => $author_mail));
+    $author_name = $this->randomSafeString();
+    $author_mail = $this->randomSafeString() . '@example.com';
+    $anonymous_comment3 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString(), array('name' => $author_name, 'mail' => $author_mail));
     $this->assertTrue($this->commentExists($anonymous_comment3), t('Anonymous comment with contact info (required) found.'));
 
     // Make sure the user data appears correctly when editing the comment.
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
index 02b3be1..44e43f2 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentApprovalTest.php
@@ -39,8 +39,8 @@ class CommentApprovalTest extends CommentTestBase {
     $this->drupalLogout();
 
     // Post anonymous comment without contact info.
-    $subject = $this->randomName();
-    $body = $this->randomName();
+    $subject = $this->randomSafeString();
+    $body = $this->randomSafeString();
     $this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
     $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
 
@@ -61,8 +61,8 @@ class CommentApprovalTest extends CommentTestBase {
     $this->assertTrue($this->commentExists($anonymous_comment4), t('Anonymous comment visible.'));
 
     // Post 2 anonymous comments without contact info.
-    $comments[] = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Publish multiple comments in one operation.
     $this->drupalLogin($this->admin_user);
@@ -103,8 +103,8 @@ class CommentApprovalTest extends CommentTestBase {
     $this->drupalLogout();
 
     // Post anonymous comment without contact info.
-    $subject = $this->randomName();
-    $body = $this->randomName();
+    $subject = $this->randomSafeString();
+    $body = $this->randomSafeString();
     $this->postComment($this->node, $body, $subject, TRUE); // Set $contact to true so that it won't check for id and message.
     $this->assertText(t('Your comment has been queued for review by site administrators and will be published after approval.'), t('Comment requires approval.'));
 
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php
index b43029f..73b2bf2 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentBlockTest.php
@@ -34,16 +34,16 @@ class CommentBlockTest extends CommentTestBase {
 
     // Set block title and variables.
     $block = array(
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
       'comment_block_count' => 2,
     );
     $this->drupalPost('admin/structure/block/manage/comment/recent/configure', $block, t('Save block'));
     $this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
 
     // Add some test comments, one without a subject.
-    $comment1 = $this->postComment($this->node, $this->randomName(), $this->randomName());
-    $comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
-    $comment3 = $this->postComment($this->node, $this->randomName());
+    $comment1 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
+    $comment2 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
+    $comment3 = $this->postComment($this->node, $this->randomSafeString());
 
     // Test that a user without the 'access comments' permission cannot see the
     // block.
@@ -78,7 +78,7 @@ class CommentBlockTest extends CommentTestBase {
     $this->assertText(t('The block configuration has been saved.'), t('Block saved.'));
 
     // Post an additional comment.
-    $comment4 = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $comment4 = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
 
     // Test that all four comments are shown.
     $this->assertText($comment1->subject, t('Comment found in block.'));
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
index 2119fe0..e27d8f6 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
@@ -31,14 +31,14 @@ class CommentContentRebuildTest extends CommentTestBase {
 
     // Log in as the web user and add the comment.
     $this->drupalLogin($this->web_user);
-    $subject_text = $this->randomName();
-    $comment_text = $this->randomName();
+    $subject_text = $this->randomSafeString();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), t('Comment found.'));
 
     // Add the property to the content array and then see if it still exists on build.
-    $comment_loaded->content['test_property'] = array('#value' => $this->randomString());
+    $comment_loaded->content['test_property'] = array('#value' => $this->randomUnsafeString());
     $built_content = comment_view($comment_loaded, $this->node);
 
     // This means that the content was rebuilt as the added test property no longer exists.
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
index 44c79b2..94f42fb 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php
@@ -91,8 +91,8 @@ class CommentFieldsTest extends CommentTestBase {
     // asserting that the body is actually posted correctly.
     $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'post comments', 'skip comment approval'));
     $this->drupalLogin($this->web_user);
-    $this->postComment($book_node, $this->randomName(), $this->randomName());
-    $this->postComment($poll_node, $this->randomName(), $this->randomName());
+    $this->postComment($book_node, $this->randomSafeString(), $this->randomSafeString());
+    $this->postComment($poll_node, $this->randomSafeString(), $this->randomSafeString());
   }
 
   /**
@@ -106,7 +106,7 @@ class CommentFieldsTest extends CommentTestBase {
 
     // Post a comment without an explicit subject.
     $this->drupalLogin($this->web_user);
-    $edit = array('comment_body[und][0][value]' => $this->randomName(8));
+    $edit = array('comment_body[und][0][value]' => $this->randomSafeString(8));
     $this->drupalPost('node/' . $this->node->nid, $edit, t('Save'));
   }
 }
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
index b7f42ae..4ba312a 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
@@ -31,7 +31,7 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Post comment #1 without subject or preview.
     $this->drupalLogin($this->web_user);
-    $comment_text = $this->randomName();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), t('Comment found.'));
@@ -45,8 +45,8 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Create comment #2 that allows subject and requires preview.
     $this->drupalLogin($this->web_user);
-    $subject_text = $this->randomName();
-    $comment_text = $this->randomName();
+    $subject_text = $this->randomSafeString();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), t('Comment found.'));
@@ -69,7 +69,7 @@ class CommentInterfaceTest extends CommentTestBase {
     $this->assertTrue(empty($comment_loaded->name) && $comment_loaded->uid == 0, t('Comment author successfully changed to anonymous.'));
 
     // Test changing the comment author to an unverified user.
-    $random_name = $this->randomName();
+    $random_name = $this->randomSafeString();
     $this->drupalGet('comment/' . $comment->id . '/edit');
     $comment = $this->postComment(NULL, $comment->comment, $comment->subject, array('name' => $random_name));
     $this->drupalGet('node/' . $this->node->nid);
@@ -89,7 +89,7 @@ class CommentInterfaceTest extends CommentTestBase {
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
     $this->assertText($subject_text, t('Individual comment-reply subject found.'));
     $this->assertText($comment_text, t('Individual comment-reply body found.'));
-    $reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), '', TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), t('Reply found.'));
     $this->assertEqual($comment->id, $reply_loaded->pid, t('Pid of a reply to a comment is set correctly.'));
@@ -99,14 +99,14 @@ class CommentInterfaceTest extends CommentTestBase {
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
     $this->assertText($subject_text, t('Individual comment-reply subject found.'));
     $this->assertText($comment_text, t('Individual comment-reply body found.'));
-    $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), t('Second reply found.'));
     $this->assertEqual(rtrim($comment_loaded->thread, '/') . '.01/', $reply_loaded->thread, t('Thread of second reply grows correctly.'));
 
     // Edit reply.
     $this->drupalGet('comment/' . $reply->id . '/edit');
-    $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $this->assertTrue($this->commentExists($reply, TRUE), t('Modified reply found.'));
 
     // Correct link count
@@ -115,7 +115,7 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Confirm a new comment is posted to the correct page.
     $this->setCommentsPerPage(2);
-    $comment_new_page = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
+    $comment_new_page = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $this->assertTrue($this->commentExists($comment_new_page), t('Page one exists. %s'));
     $this->drupalGet('node/' . $this->node->nid, array('query' => array('page' => 1)));
     $this->assertTrue($this->commentExists($reply, TRUE), t('Page two exists. %s'));
@@ -166,7 +166,7 @@ class CommentInterfaceTest extends CommentTestBase {
     // Submit comment through node form.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('node/' . $this->node->nid);
-    $form_comment = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $form_comment = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $this->assertTrue($this->commentExists($form_comment), t('Form comment found.'));
 
     // Disable comment form on node page.
@@ -199,10 +199,10 @@ class CommentInterfaceTest extends CommentTestBase {
       'pid' => 0,
       'uid' => $this->loggedInUser->uid,
       'status' => COMMENT_PUBLISHED,
-      'subject' => $this->randomName(),
+      'subject' => $this->randomSafeString(),
       'hostname' => ip_address(),
       'langcode' => LANGUAGE_NOT_SPECIFIED,
-      'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+      'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomSafeString())),
     ));
     comment_save($comment);
     $this->drupalLogout();
@@ -247,9 +247,9 @@ class CommentInterfaceTest extends CommentTestBase {
         'nid' => $node->nid,
         'uid' => $case['comment_uid'],
         'status' => $case['comment_status'],
-        'subject' => $this->randomName(),
+        'subject' => $this->randomSafeString(),
         'language' => LANGUAGE_NOT_SPECIFIED,
-        'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+        'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomSafeString())),
       ));
       comment_save($comment);
 
@@ -357,7 +357,7 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Post comment #1 as web_user2.
     $this->drupalLogin($this->web_user2);
-    $comment_text = $this->randomName();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text);
     $comment_loaded = comment_load($comment->id);
 
@@ -382,7 +382,7 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Post comment #2 as anonymous (comment approval enabled).
     $this->drupalGet('comment/reply/' . $this->node->nid);
-    $anonymous_comment = $this->postComment($this->node, $this->randomName(), '', TRUE);
+    $anonymous_comment = $this->postComment($this->node, $this->randomSafeString(), '', TRUE);
     $comment_unpublished_loaded = comment_load($anonymous_comment->id);
 
     // Checks the new values of node comment statistics with comment #2 and
@@ -404,7 +404,7 @@ class CommentInterfaceTest extends CommentTestBase {
 
     // Post comment #3 as anonymous.
     $this->drupalGet('comment/reply/' . $this->node->nid);
-    $anonymous_comment = $this->postComment($this->node, $this->randomName(), '', array('name' => $this->randomName()));
+    $anonymous_comment = $this->postComment($this->node, $this->randomSafeString(), '', array('name' => $this->randomSafeString()));
     $comment_loaded = comment_load($anonymous_comment->id);
 
     // Checks the new values of node comment statistics with comment #3.
@@ -528,10 +528,10 @@ class CommentInterfaceTest extends CommentTestBase {
           'pid' => 0,
           'uid' => 0,
           'status' => COMMENT_PUBLISHED,
-          'subject' => $this->randomName(),
+          'subject' => $this->randomSafeString(),
           'hostname' => ip_address(),
           'langcode' => LANGUAGE_NOT_SPECIFIED,
-          'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
+          'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomSafeString())),
         ));
         comment_save($comment);
         $this->comment = $comment;
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
index c6d48a5..eccd9ed 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
@@ -50,8 +50,8 @@ class CommentNodeAccessTest extends CommentTestBase {
 
     // Post comment.
     $this->drupalLogin($this->web_user);
-    $comment_text = $this->randomName();
-    $comment_subject = $this->randomName();
+    $comment_text = $this->randomSafeString();
+    $comment_subject = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $comment_subject);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), t('Comment found.'));
@@ -63,8 +63,8 @@ class CommentNodeAccessTest extends CommentTestBase {
 
     // Reply to comment, creating second comment.
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
-    $reply_text = $this->randomName();
-    $reply_subject = $this->randomName();
+    $reply_text = $this->randomSafeString();
+    $reply_subject = $this->randomSafeString();
     $reply = $this->postComment(NULL, $reply_text, $reply_subject, TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), t('Reply found.'));
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php
index b517d04..17e063f 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeChangesTest.php
@@ -25,7 +25,7 @@ class CommentNodeChangesTest extends CommentTestBase {
    */
   function testNodeDeletion() {
     $this->drupalLogin($this->web_user);
-    $comment = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $comment = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
     $this->assertTrue(comment_load($comment->id), 'The comment could be loaded.');
     node_delete($this->node->nid);
     $this->assertFalse(comment_load($comment->id), 'The comment could not be loaded after the node was deleted.');
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php
index df7c8f1..8d9eada 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php
@@ -33,9 +33,9 @@ class CommentPagerTest extends CommentTestBase {
     // Create a node and three comments.
     $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
     $comments = array();
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
 
@@ -67,7 +67,7 @@ class CommentPagerTest extends CommentTestBase {
     $replies = array();
     $oldest_comment = reset($comments);
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $oldest_comment->id);
-    $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     $this->setCommentsPerPage(2);
     // We are still in flat view - the replies should not be on the first page,
@@ -85,7 +85,7 @@ class CommentPagerTest extends CommentTestBase {
 
     // If (# replies > # comments per page) in threaded expanded view,
     // the overage should be bumped.
-    $reply2 = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply2 = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
     $this->assertFalse($this->commentExists($reply2, TRUE), t('In threaded mode where # replies > # comments per page, the newest reply does not appear on page 1.'));
 
@@ -109,25 +109,25 @@ class CommentPagerTest extends CommentTestBase {
     // Create a node and three comments.
     $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
     $comments = array();
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the second comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[1]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the first comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[0]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the last comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[2]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the second comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[3]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // At this point, the comment tree is:
     // - 0
@@ -210,21 +210,21 @@ class CommentPagerTest extends CommentTestBase {
     // Create a node and three comments.
     $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
     $comments = array();
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
-    $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
+    $comments[] = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the second comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[1]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the first comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[0]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the last comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $comments[2]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // At this point, the comment tree is:
     // - 0
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
index e6eef56..7145452 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
@@ -37,7 +37,7 @@ class CommentPreviewTest extends CommentTestBase {
     $this->drupalLogin($this->web_user);
     variable_set('user_signatures', 1);
     variable_set('user_pictures', 1);
-    $test_signature = $this->randomName();
+    $test_signature = $this->randomSafeString();
     $edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
     $edit['signature[format]'] = 'filtered_html';
     $image = current($this->drupalGetTestFiles('image'));
@@ -46,8 +46,8 @@ class CommentPreviewTest extends CommentTestBase {
 
     // As the web user, fill in the comment form and preview the comment.
     $edit = array();
-    $edit['subject'] = $this->randomName(8);
-    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
+    $edit['subject'] = $this->randomSafeString(8);
+    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomSafeString(16);
     $this->drupalPost('node/' . $this->node->nid, $edit, t('Preview'));
 
     // Check that the preview is displaying the title and body.
@@ -79,8 +79,8 @@ class CommentPreviewTest extends CommentTestBase {
     $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
 
     $edit = array();
-    $edit['subject'] = $this->randomName(8);
-    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
+    $edit['subject'] = $this->randomSafeString(8);
+    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomSafeString(16);
     $edit['name'] = $web_user->name;
     $edit['date'] = '2008-03-02 17:23 +0300';
     $raw_date = strtotime($edit['date']);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php
index 3c9559f..ab7d3fb 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php
@@ -25,7 +25,7 @@ class CommentRssTest extends CommentTestBase {
   function testCommentRss() {
     // Find comment in RSS feed.
     $this->drupalLogin($this->web_user);
-    $comment = $this->postComment($this->node, $this->randomName(), $this->randomName());
+    $comment = $this->postComment($this->node, $this->randomSafeString(), $this->randomSafeString());
     $this->drupalGet('rss.xml');
     $raw = '<comments>' . url('node/' . $this->node->nid, array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
     $this->assertRaw($raw, t('Comments as part of RSS feed.'));
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
index 1c57146..3543c59 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
@@ -38,8 +38,8 @@ class CommentThreadingTest extends CommentTestBase {
 
     // Post comment #1.
     $this->drupalLogin($this->web_user);
-    $subject_text = $this->randomName();
-    $comment_text = $this->randomName();
+    $subject_text = $this->randomSafeString();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), 'Comment #1. Comment found.');
@@ -48,14 +48,14 @@ class CommentThreadingTest extends CommentTestBase {
     // Reply to comment #1 creating comment #2.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
-    $reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), '', TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #2. Reply found.');
     $this->assertEqual($reply_loaded->thread, '01.00/');
 
     // Reply to comment #2 creating comment #3.
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $reply->id);
-    $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #3. Second reply found.');
     $this->assertEqual($reply_loaded->thread, '01.00.00/');
@@ -63,15 +63,15 @@ class CommentThreadingTest extends CommentTestBase {
     // Reply to comment #1 creating comment #4.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
-    $reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), '', TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($comment), 'Comment #4. Third reply found.');
     $this->assertEqual($reply_loaded->thread, '01.01/');
 
     // Post comment #2 overall comment #5.
     $this->drupalLogin($this->web_user);
-    $subject_text = $this->randomName();
-    $comment_text = $this->randomName();
+    $subject_text = $this->randomSafeString();
+    $comment_text = $this->randomSafeString();
     $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
     $comment_loaded = comment_load($comment->id);
     $this->assertTrue($this->commentExists($comment), 'Comment #5. Second comment found.');
@@ -80,14 +80,14 @@ class CommentThreadingTest extends CommentTestBase {
     // Reply to comment #5 creating comment #6.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
-    $reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), '', TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #6. Reply found.');
     $this->assertEqual($reply_loaded->thread, '02.00/');
 
     // Reply to comment #6 creating comment #7.
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $reply->id);
-    $reply = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($reply, TRUE), 'Comment #7. Second reply found.');
     $this->assertEqual($reply_loaded->thread, '02.00.00/');
@@ -95,7 +95,7 @@ class CommentThreadingTest extends CommentTestBase {
     // Reply to comment #5 creating comment #8.
     $this->drupalLogin($this->web_user);
     $this->drupalGet('comment/reply/' . $this->node->nid . '/' . $comment->id);
-    $reply = $this->postComment(NULL, $this->randomName(), '', TRUE);
+    $reply = $this->postComment(NULL, $this->randomSafeString(), '', TRUE);
     $reply_loaded = comment_load($reply->id);
     $this->assertTrue($this->commentExists($comment), 'Comment #8. Third reply found.');
     $this->assertEqual($reply_loaded->thread, '02.01/');
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
index aea41ef..015dfac 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php
@@ -36,11 +36,11 @@ class CommentTokenReplaceTest extends CommentTestBase {
 
     // Create a node and a comment.
     $node = $this->drupalCreateNode(array('type' => 'article'));
-    $parent_comment = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE);
+    $parent_comment = $this->postComment($node, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Post a reply to the comment.
     $this->drupalGet('comment/reply/' . $node->nid . '/' . $parent_comment->id);
-    $child_comment = $this->postComment(NULL, $this->randomName(), $this->randomName());
+    $child_comment = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString());
     $comment = comment_load($child_comment->id);
     $comment->homepage = 'http://example.org/';
 
diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
index bfd27ac..40f8a7f 100644
--- a/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
+++ b/core/modules/config/lib/Drupal/config/Tests/ConfigFileContentTest.php
@@ -200,7 +200,7 @@ class ConfigFileContentTest extends WebTestBase {
    * Tests serialization of configuration to file.
    */
   function testConfigSerialization() {
-    $name = $this->randomName(10) . '.' . $this->randomName(10);
+    $name = $this->randomSafeString(10) . '.' . $this->randomSafeString(10);
     $config_data = array(
       // Indexed arrays; the order of elements is essential.
       'numeric keys' => array('i', 'n', 'd', 'e', 'x', 'e', 'd'),
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
index 8b68d6f..25f2574 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php
@@ -141,8 +141,8 @@ class ContactPersonalTest extends WebTestBase {
    */
   protected function submitPersonalContact($account, array $message = array()) {
     $message += array(
-      'subject' => $this->randomName(16),
-      'message' => $this->randomName(64),
+      'subject' => $this->randomSafeString(16),
+      'message' => $this->randomSafeString(64),
     );
     $this->drupalPost('user/' . $account->uid . '/contact', $message, t('Send message'));
   }
diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
index 6136133..ab282e9 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
@@ -60,7 +60,7 @@ class ContactSitewideTest extends WebTestBase {
     // Test invalid recipients.
     $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com');
     foreach ($invalid_recipients as $invalid_recipient) {
-      $this->addCategory($this->randomName(16), $invalid_recipient, '', FALSE);
+      $this->addCategory($this->randomSafeString(16), $invalid_recipient, '', FALSE);
       $this->assertRaw(t('%recipient is an invalid e-mail address.', array('%recipient' => $invalid_recipient)), t('Caught invalid recipient (' . $invalid_recipient . ').'));
     }
 
@@ -71,7 +71,7 @@ class ContactSitewideTest extends WebTestBase {
 
     // Create first valid category.
     $recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com');
-    $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0])), '', TRUE);
+    $this->addCategory($category = $this->randomSafeString(16), implode(',', array($recipients[0])), '', TRUE);
     $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.'));
 
     // Make sure the newly created category is included in the list of categories.
@@ -79,7 +79,7 @@ class ContactSitewideTest extends WebTestBase {
 
     // Test update contact form category.
     $categories = $this->getCategories();
-    $category_id = $this->updateCategory($categories, $category = $this->randomName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomName(30), FALSE);
+    $category_id = $this->updateCategory($categories, $category = $this->randomSafeString(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomSafeString(30), FALSE);
     $category_array = db_query("SELECT category, recipients, reply, selected FROM {contact} WHERE cid = :cid", array(':cid' => $category_id))->fetchAssoc();
     $this->assertEqual($category_array['category'], $category);
     $this->assertEqual($category_array['recipients'], $recipients_str);
@@ -96,10 +96,10 @@ class ContactSitewideTest extends WebTestBase {
     $this->drupalLogin($admin_user);
 
     // Add more categories.
-    $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE);
+    $this->addCategory($category = $this->randomSafeString(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE);
     $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.'));
 
-    $this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE);
+    $this->addCategory($category = $this->randomSafeString(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE);
     $this->assertRaw(t('Category %category has been saved.', array('%category' => $category)), t('Category successfully saved.'));
 
     // Try adding a category that already exists.
@@ -124,19 +124,19 @@ class ContactSitewideTest extends WebTestBase {
     $this->assertResponse(200, t('Access granted to anonymous user with permission.'));
 
     // Submit contact form with invalid values.
-    $this->submitContact('', $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64));
+    $this->submitContact('', $recipients[0], $this->randomSafeString(16), $categories[0], $this->randomSafeString(64));
     $this->assertText(t('Your name field is required.'), t('Name required.'));
 
-    $this->submitContact($this->randomName(16), '', $this->randomName(16), $categories[0], $this->randomName(64));
+    $this->submitContact($this->randomSafeString(16), '', $this->randomSafeString(16), $categories[0], $this->randomSafeString(64));
     $this->assertText(t('Your e-mail address field is required.'), t('E-mail required.'));
 
-    $this->submitContact($this->randomName(16), $invalid_recipients[0], $this->randomName(16), $categories[0], $this->randomName(64));
+    $this->submitContact($this->randomSafeString(16), $invalid_recipients[0], $this->randomSafeString(16), $categories[0], $this->randomSafeString(64));
     $this->assertRaw(t('The e-mail address %mail is not valid.', array('%mail' => 'invalid')), 'Valid e-mail required.');
 
-    $this->submitContact($this->randomName(16), $recipients[0], '', $categories[0], $this->randomName(64));
+    $this->submitContact($this->randomSafeString(16), $recipients[0], '', $categories[0], $this->randomSafeString(64));
     $this->assertText(t('Subject field is required.'), t('Subject required.'));
 
-    $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], '');
+    $this->submitContact($this->randomSafeString(16), $recipients[0], $this->randomSafeString(16), $categories[0], '');
     $this->assertText(t('Message field is required.'), t('Message required.'));
 
     // Test contact form with no default category selected.
@@ -147,12 +147,12 @@ class ContactSitewideTest extends WebTestBase {
     $this->assertRaw(t('- Please choose -'), t('Without selected categories the visitor is asked to chose a category.'));
 
     // Submit contact form with invalid category id (cid 0).
-    $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), 0, '');
+    $this->submitContact($this->randomSafeString(16), $recipients[0], $this->randomSafeString(16), 0, '');
     $this->assertText(t('You must select a valid category.'), t('Valid category required.'));
 
     // Submit contact form with correct values and check flood interval.
     for ($i = 0; $i < $flood_limit; $i++) {
-      $this->submitContact($this->randomName(16), $recipients[0], $this->randomName(16), $categories[0], $this->randomName(64));
+      $this->submitContact($this->randomSafeString(16), $recipients[0], $this->randomSafeString(16), $categories[0], $this->randomSafeString(64));
       $this->assertText(t('Your message has been sent.'), t('Message sent.'));
     }
     // Submit contact form one over limit.
@@ -174,16 +174,16 @@ class ContactSitewideTest extends WebTestBase {
     $this->drupalLogin($admin_user);
 
     // Set up three categories, 2 with an auto-reply and one without.
-    $foo_autoreply = $this->randomName(40);
-    $bar_autoreply = $this->randomName(40);
+    $foo_autoreply = $this->randomSafeString(40);
+    $bar_autoreply = $this->randomSafeString(40);
     $this->addCategory('foo', 'foo@example.com', $foo_autoreply, FALSE);
     $this->addCategory('bar', 'bar@example.com', $bar_autoreply, FALSE);
     $this->addCategory('no_autoreply', 'bar@example.com', '', FALSE);
 
     // Test the auto-reply for category 'foo'.
-    $email = $this->randomName(32) . '@example.com';
-    $subject = $this->randomName(64);
-    $this->submitContact($this->randomName(16), $email, $subject, 2, $this->randomString(128));
+    $email = $this->randomSafeString(32) . '@example.com';
+    $subject = $this->randomSafeString(64);
+    $this->submitContact($this->randomSafeString(16), $email, $subject, 2, $this->randomUnsafeString(128));
 
     // We are testing the auto-reply, so there should be one e-mail going to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'foo@example.com'));
@@ -191,8 +191,8 @@ class ContactSitewideTest extends WebTestBase {
     $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($foo_autoreply), t('Auto-reply e-mail body is correct for category "foo".'), t('Contact'));
 
     // Test the auto-reply for category 'bar'.
-    $email = $this->randomName(32) . '@example.com';
-    $this->submitContact($this->randomName(16), $email, $this->randomString(64), 3, $this->randomString(128));
+    $email = $this->randomSafeString(32) . '@example.com';
+    $this->submitContact($this->randomSafeString(16), $email, $this->randomUnsafeString(64), 3, $this->randomUnsafeString(128));
 
     // Auto-reply for category 'bar' should result in one auto-reply e-mail to the sender.
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'bar@example.com'));
@@ -200,8 +200,8 @@ class ContactSitewideTest extends WebTestBase {
     $this->assertEqual($captured_emails[0]['body'], drupal_html_to_text($bar_autoreply), t('Auto-reply e-mail body is correct for category "bar".'), t('Contact'));
 
     // Verify that no auto-reply is sent when the auto-reply field is left blank.
-    $email = $this->randomName(32) . '@example.com';
-    $this->submitContact($this->randomName(16), $email, $this->randomString(64), 4, $this->randomString(128));
+    $email = $this->randomSafeString(32) . '@example.com';
+    $this->submitContact($this->randomSafeString(16), $email, $this->randomUnsafeString(64), 4, $this->randomUnsafeString(128));
     $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email, 'from' => 'no_autoreply@example.com'));
     $this->assertEqual(count($captured_emails), 0, t('No auto-reply e-mail was sent to the sender for category "no-autoreply".'), t('Contact'));
   }
diff --git a/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php
index a772388..ee012b0 100644
--- a/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php
+++ b/core/modules/dashboard/lib/Drupal/dashboard/Tests/DashboardBlocksTest.php
@@ -35,9 +35,9 @@ class DashboardBlocksTest extends WebTestBase {
   function testDashboardAccess() {
     // Add a new custom block to a dashboard region.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
-    $custom_block['title'] = $this->randomName(8);
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['info'] = $this->randomSafeString(8);
+    $custom_block['title'] = $this->randomSafeString(8);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $custom_block['regions[stark]'] = 'dashboard_main';
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
 
@@ -83,9 +83,9 @@ class DashboardBlocksTest extends WebTestBase {
   function testDisableEnable() {
     // Add a new custom block to a dashboard region.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
-    $custom_block['title'] = $this->randomName(8);
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['info'] = $this->randomSafeString(8);
+    $custom_block['title'] = $this->randomSafeString(8);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $custom_block['regions[stark]'] = 'dashboard_main';
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
     $this->drupalGet('admin/dashboard');
diff --git a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php
index ce02b0a..b94043e 100644
--- a/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php
+++ b/core/modules/dblog/lib/Drupal/dblog/Tests/DBLogTest.php
@@ -190,7 +190,7 @@ class DBLogTest extends WebTestBase {
    */
   private function doUser() {
     // Set user variables.
-    $name = $this->randomName();
+    $name = $this->randomSafeString();
     $pass = user_password();
     // Add user using form to generate add user event (which is not triggered by drupalCreateUser).
     $edit = array();
@@ -256,7 +256,7 @@ class DBLogTest extends WebTestBase {
     }
     $this->assertTrue($link, t('DBLog event was recorded: [delete user]'));
     // Visit random URL (to generate page not found event).
-    $not_found_url = $this->randomName(60);
+    $not_found_url = $this->randomSafeString(60);
     $this->drupalGet($not_found_url);
     $this->assertResponse(404);
     // View dblog page-not-found report page.
@@ -339,16 +339,16 @@ class DBLogTest extends WebTestBase {
     switch ($type) {
       case 'poll':
         $content = array(
-          "title" => $this->randomName(8),
-          'choice[new:0][chtext]' => $this->randomName(32),
-          'choice[new:1][chtext]' => $this->randomName(32),
+          "title" => $this->randomSafeString(8),
+          'choice[new:0][chtext]' => $this->randomSafeString(32),
+          'choice[new:1][chtext]' => $this->randomSafeString(32),
         );
       break;
 
       default:
         $content = array(
-          "title" => $this->randomName(8),
-          "body[$langcode][0][value]" => $this->randomName(32),
+          "title" => $this->randomSafeString(8),
+          "body[$langcode][0][value]" => $this->randomSafeString(32),
         );
       break;
     }
@@ -365,15 +365,15 @@ class DBLogTest extends WebTestBase {
     switch ($type) {
       case 'poll':
         $content = array(
-          'choice[chid:1][chtext]' => $this->randomName(32),
-          'choice[chid:2][chtext]' => $this->randomName(32),
+          'choice[chid:1][chtext]' => $this->randomSafeString(32),
+          'choice[chid:2][chtext]' => $this->randomSafeString(32),
         );
       break;
 
       default:
         $langcode = LANGUAGE_NOT_SPECIFIED;
         $content = array(
-          "body[$langcode][0][value]" => $this->randomName(32),
+          "body[$langcode][0][value]" => $this->randomSafeString(32),
         );
       break;
     }
@@ -426,7 +426,7 @@ class DBLogTest extends WebTestBase {
     $type_names = array();
     $types = array();
     for ($i = 0; $i < 3; $i++) {
-      $type_names[] = $type_name = $this->randomName();
+      $type_names[] = $type_name = $this->randomSafeString();
       $severity = WATCHDOG_EMERGENCY;
       for ($j = 0; $j < 3; $j++) {
         $types[] = $type = array(
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityFieldQueryTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityFieldQueryTest.php
index 9b4a91c..1244886 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityFieldQueryTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityFieldQueryTest.php
@@ -36,7 +36,7 @@ class EntityFieldQueryTest extends WebTestBase {
 
     $instances = array();
     $this->fields = array();
-    $this->field_names[0] = $field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_names[0] = $field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $field = array('field_name' => $field_name, 'type' => 'test_field', 'cardinality' => 4);
     $field = field_create_field($field);
     $this->fields[0] = $field;
@@ -44,17 +44,17 @@ class EntityFieldQueryTest extends WebTestBase {
       'field_name' => $field_name,
       'entity_type' => '',
       'bundle' => '',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'label' => $this->randomSafeString() . '_label',
+      'description' => $this->randomSafeString() . '_description',
       'weight' => mt_rand(0, 127),
       'settings' => array(
-        'test_instance_setting' => $this->randomName(),
+        'test_instance_setting' => $this->randomSafeString(),
       ),
       'widget' => array(
         'type' => 'test_field_widget',
         'label' => 'Test Field',
         'settings' => array(
-          'test_widget_setting' => $this->randomName(),
+          'test_widget_setting' => $this->randomSafeString(),
         )
       )
     );
@@ -70,7 +70,7 @@ class EntityFieldQueryTest extends WebTestBase {
     $instances[0]['bundle'] = $instances[0]['entity_type'] = 'test_entity_bundle';
     field_create_instance($instances[0]);
 
-    $this->field_names[1] = $field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_names[1] = $field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $field = array('field_name' => $field_name, 'type' => 'shape', 'cardinality' => 4);
     $field = field_create_field($field);
     $this->fields[1] = $field;
@@ -78,17 +78,17 @@ class EntityFieldQueryTest extends WebTestBase {
       'field_name' => $field_name,
       'entity_type' => '',
       'bundle' => '',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'label' => $this->randomSafeString() . '_label',
+      'description' => $this->randomSafeString() . '_description',
       'weight' => mt_rand(0, 127),
       'settings' => array(
-        'test_instance_setting' => $this->randomName(),
+        'test_instance_setting' => $this->randomSafeString(),
       ),
       'widget' => array(
         'type' => 'test_field_widget',
         'label' => 'Test Field',
         'settings' => array(
-          'test_widget_setting' => $this->randomName(),
+          'test_widget_setting' => $this->randomSafeString(),
         )
       )
     );
diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
index 99842e5..c9ec82f 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
@@ -28,7 +28,7 @@ class EntityTranslationTest extends WebTestBase {
     variable_set('entity_test_translation', TRUE);
 
     // Create a translatable test field.
-    $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $field = array(
       'field_name' => $this->field_name,
       'type' => 'text',
@@ -51,7 +51,7 @@ class EntityTranslationTest extends WebTestBase {
     for ($i = 0; $i < 3; ++$i) {
       $language = (object) array(
         'langcode' => 'l' . $i,
-        'name' => $this->randomString(),
+        'name' => $this->randomUnsafeString(),
       );
       $this->langcodes[$i] = $language->langcode;
       language_save($language);
diff --git a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
index f848367..1b2c337 100644
--- a/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/DisplayApiTest.php
@@ -21,7 +21,7 @@ class DisplayApiTest extends FieldTestBase {
 
     // Create a field and instance.
     $this->field_name = 'test_field';
-    $this->label = $this->randomName();
+    $this->label = $this->randomSafeString();
     $this->cardinality = 4;
 
     $this->field = array(
@@ -38,13 +38,13 @@ class DisplayApiTest extends FieldTestBase {
         'default' => array(
           'type' => 'field_test_default',
           'settings' => array(
-            'test_formatter_setting' => $this->randomName(),
+            'test_formatter_setting' => $this->randomSafeString(),
           ),
         ),
         'teaser' => array(
           'type' => 'field_test_default',
           'settings' => array(
-            'test_formatter_setting' => $this->randomName(),
+            'test_formatter_setting' => $this->randomSafeString(),
           ),
         ),
       ),
@@ -79,7 +79,7 @@ class DisplayApiTest extends FieldTestBase {
       'label' => 'hidden',
       'type' => 'field_test_multiple',
       'settings' => array(
-        'test_formatter_setting_multiple' => $this->randomName(),
+        'test_formatter_setting_multiple' => $this->randomSafeString(),
         'alter' => TRUE,
       ),
     );
@@ -99,7 +99,7 @@ class DisplayApiTest extends FieldTestBase {
       'label' => 'hidden',
       'type' => 'field_test_with_prepare_view',
       'settings' => array(
-        'test_formatter_setting_additional' => $this->randomName(),
+        'test_formatter_setting_additional' => $this->randomSafeString(),
       ),
     );
     $output = field_view_field('test_entity', $this->entity, $this->field_name, $display);
@@ -151,7 +151,7 @@ class DisplayApiTest extends FieldTestBase {
     $display = array(
       'type' => 'field_test_multiple',
       'settings' => array(
-        'test_formatter_setting_multiple' => $this->randomName(),
+        'test_formatter_setting_multiple' => $this->randomSafeString(),
       ),
     );
     $setting = $display['settings']['test_formatter_setting_multiple'];
@@ -167,7 +167,7 @@ class DisplayApiTest extends FieldTestBase {
     $display = array(
       'type' => 'field_test_with_prepare_view',
       'settings' => array(
-        'test_formatter_setting_additional' => $this->randomName(),
+        'test_formatter_setting_additional' => $this->randomSafeString(),
       ),
     );
     $setting = $display['settings']['test_formatter_setting_additional'];
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
index 1916932..c2b59cb 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php
@@ -35,7 +35,7 @@ class FieldAttachOtherTest extends FieldAttachTestBase {
 
     // Simple formatter, label displayed.
     $entity = clone($entity_init);
-    $formatter_setting = $this->randomName();
+    $formatter_setting = $this->randomSafeString();
     $this->instance['display'] = array(
       'full' => array(
         'label' => 'above',
@@ -86,7 +86,7 @@ class FieldAttachOtherTest extends FieldAttachTestBase {
 
     // Multiple formatter.
     $entity = clone($entity_init);
-    $formatter_setting = $this->randomName();
+    $formatter_setting = $this->randomSafeString();
     $this->instance['display'] = array(
       'full' => array(
         'label' => 'above',
@@ -109,7 +109,7 @@ class FieldAttachOtherTest extends FieldAttachTestBase {
 
     // Test a formatter that uses hook_field_formatter_prepare_view().
     $entity = clone($entity_init);
-    $formatter_setting = $this->randomName();
+    $formatter_setting = $this->randomSafeString();
     $this->instance['display'] = array(
       'full' => array(
         'label' => 'above',
@@ -160,7 +160,7 @@ class FieldAttachOtherTest extends FieldAttachTestBase {
     // Set up a second instance on another bundle, with a formatter that uses
     // hook_field_formatter_prepare_view().
     field_test_create_bundle('test_bundle_2');
-    $formatter_setting = $this->randomName();
+    $formatter_setting = $this->randomSafeString();
     $this->instance2 = $this->instance;
     $this->instance2['bundle'] = 'test_bundle_2';
     $this->instance2['display']['full'] = array(
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
index d6b4c18..80bd957 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php
@@ -425,7 +425,7 @@ class FieldAttachStorageTest extends FieldAttachTestBase {
   function testFieldAttachCreateRenameBundle() {
     // Create a new bundle. This has to be initiated by the module so that its
     // hook_entity_info() is consistent.
-    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName());
+    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomSafeString());
     field_test_create_bundle($new_bundle);
 
     // Add an instance to that bundle.
@@ -447,7 +447,7 @@ class FieldAttachStorageTest extends FieldAttachTestBase {
 
     // Rename the bundle. This has to be initiated by the module so that its
     // hook_entity_info() is consistent.
-    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName());
+    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomSafeString());
     field_test_rename_bundle($this->instance['bundle'], $new_bundle);
 
     // Check that the instance definition has been updated.
@@ -466,7 +466,7 @@ class FieldAttachStorageTest extends FieldAttachTestBase {
   function testFieldAttachDeleteBundle() {
     // Create a new bundle. This has to be initiated by the module so that its
     // hook_entity_info() is consistent.
-    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomName());
+    $new_bundle = 'test_bundle_' . drupal_strtolower($this->randomSafeString());
     field_test_create_bundle($new_bundle);
 
     // Add an instance to that bundle.
@@ -474,15 +474,15 @@ class FieldAttachStorageTest extends FieldAttachTestBase {
     field_create_instance($this->instance);
 
     // Create a second field for the test bundle
-    $field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $field = array('field_name' => $field_name, 'type' => 'test_field', 'cardinality' => 1);
     field_create_field($field);
     $instance = array(
       'field_name' => $field_name,
       'entity_type' => 'test_entity',
       'bundle' => $this->instance['bundle'],
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'label' => $this->randomSafeString() . '_label',
+      'description' => $this->randomSafeString() . '_description',
       'weight' => mt_rand(0, 127),
       // test_field has no instance settings
       'widget' => array(
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php
index 0e33a44..4e1ce66 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachTestBase.php
@@ -22,7 +22,7 @@ class FieldAttachTestBase extends FieldTestBase {
     }
     parent::setUp($modules);
 
-    $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4);
     $this->field = field_create_field($this->field);
     $this->field_id = $this->field['id'];
@@ -30,17 +30,17 @@ class FieldAttachTestBase extends FieldTestBase {
       'field_name' => $this->field_name,
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'label' => $this->randomSafeString() . '_label',
+      'description' => $this->randomSafeString() . '_description',
       'weight' => mt_rand(0, 127),
       'settings' => array(
-        'test_instance_setting' => $this->randomName(),
+        'test_instance_setting' => $this->randomSafeString(),
       ),
       'widget' => array(
         'type' => 'test_field_widget',
         'label' => 'Test Field',
         'settings' => array(
-          'test_widget_setting' => $this->randomName(),
+          'test_widget_setting' => $this->randomSafeString(),
         )
       )
     );
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
index d62412b..c07bfbe 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php
@@ -77,7 +77,7 @@ class FieldInfoTest extends FieldTestBase {
     // Create a field, verify it shows up.
     $core_fields = field_info_fields();
     $field = array(
-      'field_name' => drupal_strtolower($this->randomName()),
+      'field_name' => drupal_strtolower($this->randomSafeString()),
       'type' => 'test_field',
     );
     field_create_field($field);
@@ -98,8 +98,8 @@ class FieldInfoTest extends FieldTestBase {
       'field_name' => $field['field_name'],
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
-      'label' => $this->randomName(),
-      'description' => $this->randomName(),
+      'label' => $this->randomSafeString(),
+      'description' => $this->randomSafeString(),
       'weight' => mt_rand(0, 127),
       // test_field has no instance settings
       'widget' => array(
diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
index 7d1e667..a2bd376 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php
@@ -24,7 +24,7 @@ class FieldInstanceCrudTest extends FieldTestBase {
     parent::setUp('field_test');
 
     $this->field = array(
-      'field_name' => drupal_strtolower($this->randomName()),
+      'field_name' => drupal_strtolower($this->randomSafeString()),
       'type' => 'test_field',
     );
     field_create_field($this->field);
@@ -80,7 +80,7 @@ class FieldInstanceCrudTest extends FieldTestBase {
 
     // Check that the specified field exists.
     try {
-      $this->instance_definition['field_name'] = $this->randomName();
+      $this->instance_definition['field_name'] = $this->randomSafeString();
       field_create_instance($this->instance_definition);
       $this->fail(t('Cannot create an instance of a non-existing field.'));
     }
@@ -90,7 +90,7 @@ class FieldInstanceCrudTest extends FieldTestBase {
 
     // Create a field restricted to a specific entity type.
     $field_restricted = array(
-      'field_name' => drupal_strtolower($this->randomName()),
+      'field_name' => drupal_strtolower($this->randomSafeString()),
       'type' => 'test_field',
       'entity_types' => array('test_cacheable_entity'),
     );
@@ -145,12 +145,12 @@ class FieldInstanceCrudTest extends FieldTestBase {
     // Check that basic changes are saved.
     $instance = field_read_instance('test_entity', $this->instance_definition['field_name'], $this->instance_definition['bundle']);
     $instance['required'] = !$instance['required'];
-    $instance['label'] = $this->randomName();
-    $instance['description'] = $this->randomName();
-    $instance['settings']['test_instance_setting'] = $this->randomName();
-    $instance['widget']['settings']['test_widget_setting'] =$this->randomName();
+    $instance['label'] = $this->randomSafeString();
+    $instance['description'] = $this->randomSafeString();
+    $instance['settings']['test_instance_setting'] = $this->randomSafeString();
+    $instance['widget']['settings']['test_widget_setting'] =$this->randomSafeString();
     $instance['widget']['weight']++;
-    $instance['display']['default']['settings']['test_formatter_setting'] = $this->randomName();
+    $instance['display']['default']['settings']['test_formatter_setting'] = $this->randomSafeString();
     $instance['display']['default']['weight']++;
     field_update_instance($instance);
 
diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
index 8c2af9b..75ed77c 100644
--- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php
@@ -29,17 +29,17 @@ class FormTest extends FieldTestBase {
     $this->instance = array(
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
-      'label' => $this->randomName() . '_label',
-      'description' => $this->randomName() . '_description',
+      'label' => $this->randomSafeString() . '_label',
+      'description' => $this->randomSafeString() . '_description',
       'weight' => mt_rand(0, 127),
       'settings' => array(
-        'test_instance_setting' => $this->randomName(),
+        'test_instance_setting' => $this->randomSafeString(),
       ),
       'widget' => array(
         'type' => 'test_field_widget',
         'label' => 'Test Field',
         'settings' => array(
-          'test_widget_setting' => $this->randomName(),
+          'test_widget_setting' => $this->randomSafeString(),
         )
       )
     );
diff --git a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index ce76545..0f5531b 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -25,7 +25,7 @@ class TranslationTest extends FieldTestBase {
   function setUp() {
     parent::setUp('language', 'field_test');
 
-    $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
 
     $this->entity_type = 'test_entity';
 
@@ -49,7 +49,7 @@ class TranslationTest extends FieldTestBase {
     for ($i = 0; $i < 3; ++$i) {
       $language = (object) array(
         'langcode' => 'l' . $i,
-        'name' => $this->randomString(),
+        'name' => $this->randomUnsafeString(),
       );
       language_save($language);
     }
@@ -102,7 +102,7 @@ class TranslationTest extends FieldTestBase {
     $extra_langcodes = mt_rand(1, 4);
     $langcodes = $available_langcodes = field_available_languages($this->entity_type, $this->field);
     for ($i = 0; $i < $extra_langcodes; ++$i) {
-      $langcodes[] = $this->randomName(2);
+      $langcodes[] = $this->randomSafeString(2);
     }
 
     // For each given language provide some random values.
@@ -146,7 +146,7 @@ class TranslationTest extends FieldTestBase {
       // correctly uses the result of field_available_languages().
       $extra_langcodes = mt_rand(1, 4);
       for ($i = 0; $i < $extra_langcodes; ++$i) {
-        $langcodes[] = $this->randomName(2);
+        $langcodes[] = $this->randomSafeString(2);
       }
 
       // For each given language provide some random values.
@@ -238,7 +238,7 @@ class TranslationTest extends FieldTestBase {
    * Tests display language logic for translatable fields.
    */
   function testFieldDisplayLanguage() {
-    $field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $entity_type = 'test_entity';
 
     // We need an additional field here to properly test display language
diff --git a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
index 8dbb577..fb0588e 100644
--- a/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
+++ b/core/modules/field/modules/field_sql_storage/lib/Drupal/field_sql_storage/Tests/FieldSqlStorageTest.php
@@ -29,7 +29,7 @@ class FieldSqlStorageTest extends WebTestBase {
 
   function setUp() {
     parent::setUp('field_sql_storage', 'field', 'field_test', 'text', 'number');
-    $this->field_name = strtolower($this->randomName());
+    $this->field_name = strtolower($this->randomSafeString());
     $this->field = array('field_name' => $this->field_name, 'type' => 'test_field', 'cardinality' => 4);
     $this->field = field_create_field($this->field);
     $this->instance = array(
diff --git a/core/modules/field/modules/list/tests/list.test b/core/modules/field/modules/list/tests/list.test
index 65a64f7..c8d7713 100644
--- a/core/modules/field/modules/list/tests/list.test
+++ b/core/modules/field/modules/list/tests/list.test
@@ -180,7 +180,7 @@ class ListFieldUITestCase extends FieldTestBase {
     $this->drupalLogin($admin_user);
 
     // Create content type, with underscores.
-    $type_name = 'test_' . strtolower($this->randomName());
+    $type_name = 'test_' . strtolower($this->randomSafeString());
     $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
     $this->type = $type->type;
   }
@@ -310,7 +310,7 @@ class ListFieldUITestCase extends FieldTestBase {
     $array = array('zero' => 'Zero', 'One' => 'One');
     $this->assertAllowedValuesInput($string, $array, t('Mixed lists are accepted.'));
     // Overly long keys.
-    $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomName(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.'));
+    $this->assertAllowedValuesInput("zero|Zero\n" . $this->randomSafeString(256) . "|One", 'each key must be a string at most 255 characters long', t('Overly long keys are rejected.'));
 
     // Create a node with actual data for the field.
     $settings = array(
@@ -349,8 +349,8 @@ class ListFieldUITestCase extends FieldTestBase {
     $this->createListField('list_boolean');
 
     // Check that the separate 'On' and 'Off' form fields work.
-    $on = $this->randomName();
-    $off = $this->randomName();
+    $on = $this->randomSafeString();
+    $off = $this->randomSafeString();
     $allowed_values = array(1 => $on, 0 => $off);
     $edit = array(
       'on' => $on,
diff --git a/core/modules/field/modules/list/tests/list_dynamic.test b/core/modules/field/modules/list/tests/list_dynamic.test
index f562d05..631aeec 100644
--- a/core/modules/field/modules/list/tests/list_dynamic.test
+++ b/core/modules/field/modules/list/tests/list_dynamic.test
@@ -41,7 +41,7 @@ class ListDynamicValuesTestCase extends FieldTestBase {
       // list_test_dynamic_values_callback() always returns 4 values.
       'vid' => mt_rand(20, 30),
       'bundle' => 'test_bundle',
-      'label' => $this->randomName(),
+      'label' => $this->randomSafeString(),
     );
     $this->entity = call_user_func_array('field_test_create_stub_entity', $this->test);
   }
diff --git a/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php b/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
index c92970f..6e5fe95 100644
--- a/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+++ b/core/modules/field/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
@@ -37,7 +37,7 @@ class NumberFieldTest extends WebTestBase {
   function testNumberDecimalField() {
     // Create a field with settings to validate.
     $this->field = array(
-      'field_name' => drupal_strtolower($this->randomName()),
+      'field_name' => drupal_strtolower($this->randomSafeString()),
       'type' => 'number_decimal',
       'settings' => array(
         'precision' => 8, 'scale' => 4, 'decimal_separator' => '.',
@@ -120,13 +120,13 @@ class NumberFieldTest extends WebTestBase {
     $this->drupalGet('admin/structure/types/add');
 
     // Add a content type.
-    $name = $this->randomName();
+    $name = $this->randomSafeString();
     $type = drupal_strtolower($name);
     $edit = array('name' => $name, 'type' => $type);
     $this->drupalPost(NULL, $edit, t('Save and add fields'));
 
     // Add an integer field to the newly-created type.
-    $label = $this->randomName();
+    $label = $this->randomSafeString();
     $field_name = drupal_strtolower($label);
     $edit = array(
       'fields[_add_new_field][label]'=> $label,
diff --git a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
index fbbd322..e5e21c7 100644
--- a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+++ b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
@@ -43,7 +43,7 @@ class TextFieldTest extends WebTestBase {
     // Create a field with settings to validate.
     $max_length = 3;
     $this->field = array(
-      'field_name' => drupal_strtolower($this->randomName()),
+      'field_name' => drupal_strtolower($this->randomSafeString()),
       'type' => 'text',
       'settings' => array(
         'max_length' => $max_length,
@@ -93,14 +93,14 @@ class TextFieldTest extends WebTestBase {
   function _testTextfieldWidgets($field_type, $widget_type) {
     // Setup a field and instance
     $entity_type = 'test_entity';
-    $this->field_name = drupal_strtolower($this->randomName());
+    $this->field_name = drupal_strtolower($this->randomSafeString());
     $this->field = array('field_name' => $this->field_name, 'type' => $field_type);
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
-      'label' => $this->randomName() . '_label',
+      'label' => $this->randomSafeString() . '_label',
       'settings' => array(
         'text_processing' => TRUE,
       ),
@@ -122,7 +122,7 @@ class TextFieldTest extends WebTestBase {
     $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '1', t('Format selector is not displayed'));
 
     // Submit with some value.
-    $value = $this->randomName();
+    $value = $this->randomSafeString();
     $edit = array(
       "{$this->field_name}[$langcode][0][value]" => $value,
     );
@@ -152,14 +152,14 @@ class TextFieldTest extends WebTestBase {
   function _testTextfieldWidgetsFormatted($field_type, $widget_type) {
     // Setup a field and instance
     $entity_type = 'test_entity';
-    $this->field_name = drupal_strtolower($this->randomName());
+    $this->field_name = drupal_strtolower($this->randomSafeString());
     $this->field = array('field_name' => $this->field_name, 'type' => $field_type);
     field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
       'entity_type' => 'test_entity',
       'bundle' => 'test_bundle',
-      'label' => $this->randomName() . '_label',
+      'label' => $this->randomSafeString() . '_label',
       'settings' => array(
         'text_processing' => TRUE,
       ),
@@ -191,7 +191,7 @@ class TextFieldTest extends WebTestBase {
     $this->assertNoFieldByName("{$this->field_name}[$langcode][0][format]", '', t('Format selector is not displayed'));
 
     // Submit with data that should be filtered.
-    $value = '<em>' . $this->randomName() . '</em>';
+    $value = '<em>' . $this->randomSafeString() . '</em>';
     $edit = array(
       "{$this->field_name}[$langcode][0][value]" => $value,
     );
@@ -211,8 +211,8 @@ class TextFieldTest extends WebTestBase {
     // access to it.
     $this->drupalLogin($this->admin_user);
     $edit = array(
-      'format' => drupal_strtolower($this->randomName()),
-      'name' => $this->randomName(),
+      'format' => drupal_strtolower($this->randomSafeString()),
+      'name' => $this->randomSafeString(),
     );
     $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
     filter_formats_reset();
diff --git a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextSummaryTest.php b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextSummaryTest.php
index 1d588c8..60b30ea 100644
--- a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextSummaryTest.php
+++ b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextSummaryTest.php
@@ -170,9 +170,9 @@ class TextSummaryTest extends WebTestBase {
     // Login as article creator.
     $this->drupalLogin($this->article_creator);
     // Create article with summary but empty body.
-    $summary = $this->randomName();
+    $summary = $this->randomSafeString();
     $edit = array(
-      "title" => $this->randomName(),
+      "title" => $this->randomSafeString(),
       "body[und][0][summary]" => $summary,
     );
     $this->drupalPost('node/add/article', $edit, t('Save'));
diff --git a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
index 0d3739f..b944974 100644
--- a/core/modules/field/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
+++ b/core/modules/field/modules/text/lib/Drupal/text/Tests/TextTranslationTest.php
@@ -61,9 +61,9 @@ class TextTranslationTest extends WebTestBase {
 
     // Create content.
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $body = $this->randomName();
+    $body = $this->randomSafeString();
     $edit = array(
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
       'langcode' => 'en',
       "body[$langcode][0][value]" => $body,
     );
@@ -88,12 +88,12 @@ class TextTranslationTest extends WebTestBase {
     $this->assertFieldByXPath("//input[@name='body_add_more']", t('Add another item'), t('Body field cardinality set to multiple.'));
 
     $body = array(
-      $this->randomName(),
-      $this->randomName(),
+      $this->randomSafeString(),
+      $this->randomSafeString(),
     );
 
     // Create an article with the first body input format set to "Full HTML".
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $edit = array(
       'title' => $title,
       'langcode' => 'en',
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
index cc0f45d..2a82805 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php
@@ -34,7 +34,7 @@ class FieldUiTestBase extends WebTestBase {
     $this->drupalLogin($admin_user);
 
     // Create content type, with underscores.
-    $type_name = strtolower($this->randomName(8)) . '_test';
+    $type_name = strtolower($this->randomSafeString(8)) . '_test';
     $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name));
     $this->type = $type->type;
   }
diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
index af40230..17bfeb9 100644
--- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
+++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php
@@ -23,8 +23,8 @@ class ManageFieldsTest extends FieldUiTestBase {
     parent::setUp();
 
     // Create random field name.
-    $this->field_label = $this->randomName(8);
-    $this->field_name_input =  strtolower($this->randomName(8));
+    $this->field_label = $this->randomSafeString(8);
+    $this->field_name_input =  strtolower($this->randomSafeString(8));
     $this->field_name = 'field_'. $this->field_name_input;
 
     // Create Basic page and Article node types.
@@ -246,7 +246,7 @@ class ManageFieldsTest extends FieldUiTestBase {
     $this->fieldUIAddNewField($bundle_path1, $edit1);
 
     // Create an additional node type.
-    $type_name2 = strtolower($this->randomName(8)) . '_test';
+    $type_name2 = strtolower($this->randomSafeString(8)) . '_test';
     $type2 = $this->drupalCreateContentType(array('name' => $type_name2, 'type' => $type_name2));
     $type_name2 = $type2->type;
 
@@ -318,7 +318,7 @@ class ManageFieldsTest extends FieldUiTestBase {
    * Tests renaming a bundle.
    */
   function testRenameBundle() {
-    $type2 = strtolower($this->randomName(8)) . '_test';
+    $type2 = strtolower($this->randomSafeString(8)) . '_test';
 
     $options = array(
       'type' => $type2,
@@ -336,7 +336,7 @@ class ManageFieldsTest extends FieldUiTestBase {
     // create a new field with the same name.
     $edit = array(
       'fields[_add_new_field][field_name]' => 'tags',
-      'fields[_add_new_field][label]' => $this->randomName(),
+      'fields[_add_new_field][label]' => $this->randomSafeString(),
       'fields[_add_new_field][type]' => 'taxonomy_term_reference',
       'fields[_add_new_field][widget_type]' => 'options_select',
     );
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
index d5fd817..0967f90 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldDisplayTest.php
@@ -23,7 +23,7 @@ class FileFieldDisplayTest extends FileFieldTestBase {
    * Tests normal formatter display on node display.
    */
   function testNodeDisplay() {
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $type_name = 'article';
     $field_settings = array(
       'display_field' => '1',
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
index dd58f12..765c534 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldPathTest.php
@@ -23,7 +23,7 @@ class FileFieldPathTest extends FileFieldTestBase {
    * Tests the normal formatter display on node display.
    */
   function testUploadPath() {
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $type_name = 'article';
     $field = $this->createFileField($field_name, $type_name);
     $test_file = $this->getTestFile('text');
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
index 9f9448f..f5d4d2c 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php
@@ -32,7 +32,7 @@ class FileFieldRevisionTest extends FileFieldTestBase {
    */
   function testRevisions() {
     $type_name = 'article';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
index d95cf86..c51632c 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php
@@ -131,7 +131,7 @@ class FileFieldTestBase extends WebTestBase {
   function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $extras = array()) {
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array(
-      "title" => $this->randomName(),
+      "title" => $this->randomSafeString(),
       'revision' => (string) (int) $new_revision,
     );
 
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
index be37295..f7d6af7 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldValidateTest.php
@@ -27,7 +27,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
    */
   function testRequired() {
     $type_name = 'article';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
@@ -36,7 +36,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
 
     // Try to post a new node without uploading a file.
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit = array("title" => $this->randomName());
+    $edit = array("title" => $this->randomSafeString());
     $this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
     $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required file field was empty.'));
 
@@ -55,7 +55,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
     $this->createFileField($field_name, $type_name, array('cardinality' => FIELD_CARDINALITY_UNLIMITED), array('required' => '1'));
 
     // Try to post a new node without uploading a file in the multivalue field.
-    $edit = array('title' => $this->randomName());
+    $edit = array('title' => $this->randomSafeString());
     $this->drupalPost('node/add/' . $type_name, $edit, t('Save'));
     $this->assertRaw(t('!title field is required.', array('!title' => $instance['label'])), t('Node save failed when required multiple value file field was empty.'));
 
@@ -75,7 +75,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
    */
   function testFileMaxSize() {
     $type_name = 'article';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
@@ -127,7 +127,7 @@ class FileFieldValidateTest extends FileFieldTestBase {
    */
   function testFileExtension() {
     $type_name = 'article';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
index a924874..cde7cb7 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php
@@ -28,7 +28,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // own default file or image field, this test can be made more robust by
     // using a custom node type.
     $type_name = 'page';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
@@ -85,8 +85,8 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // own default file or image field, this test can be made more robust by
     // using a custom node type.
     $type_name = 'page';
-    $field_name = strtolower($this->randomName());
-    $field_name2 = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
+    $field_name2 = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name, array('cardinality' => 3));
     $this->createFileField($field_name2, $type_name, array('cardinality' => 3));
 
@@ -188,7 +188,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
       $this->assertNoFieldByXPath('//input[@type="submit"]', t('Remove'), t('After removing all files, there is no "Remove" button displayed (JSMode=%type).', array('%type' => $type)));
 
       // Save the node and ensure it does not have any files.
-      $this->drupalPost(NULL, array('title' => $this->randomName()), t('Save'));
+      $this->drupalPost(NULL, array('title' => $this->randomSafeString()), t('Save'));
       $matches = array();
       preg_match('/node\/([0-9]+)/', $this->getUrl(), $matches);
       $nid = $matches[1];
@@ -206,7 +206,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // own default file or image field, this test can be made more robust by
     // using a custom node type.
     $type_name = 'page';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
@@ -250,8 +250,8 @@ class FileFieldWidgetTest extends FileFieldTestBase {
 
     // Create a new field.
     $edit = array(
-      'fields[_add_new_field][label]' => $label = $this->randomName(),
-      'fields[_add_new_field][field_name]' => $name = strtolower($this->randomName()),
+      'fields[_add_new_field][label]' => $label = $this->randomSafeString(),
+      'fields[_add_new_field][field_name]' => $name = strtolower($this->randomSafeString()),
       'fields[_add_new_field][type]' => 'file',
       'fields[_add_new_field][widget_type]' => 'file_generic',
     );
@@ -263,7 +263,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     // Create node.
     $text_file = $this->getTestFile('text');
     $edit = array(
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
     );
     $this->drupalPost('node/add/article', $edit, t('Save'));
     $node = $this->drupalGetNodeByTitle($edit['title']);
@@ -272,7 +272,7 @@ class FileFieldWidgetTest extends FileFieldTestBase {
     $text_file = $this->getTestFile('text');
     $edit = array(
       'files[field_' . $name . '_' . LANGUAGE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($text_file->uri),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomName(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $comment_body = $this->randomSafeString(),
     );
     $this->drupalPost(NULL, $edit, t('Save'));
 
diff --git a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
index 42ee933..75067f5 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FilePrivateTest.php
@@ -34,7 +34,7 @@ class FilePrivateTest extends FileFieldTestBase {
     // own default file or image field, this test can be made more robust by
     // using a custom node type.
     $type_name = 'page';
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name, array('uri_scheme' => 'private'));
 
     $test_file = $this->getTestFile('text');
diff --git a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
index 57e9a1e..2a4782a 100644
--- a/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
+++ b/core/modules/file/lib/Drupal/file/Tests/FileTokenReplaceTest.php
@@ -31,7 +31,7 @@ class FileTokenReplaceTest extends FileFieldTestBase {
 
     // Create file field.
     $type_name = 'article';
-    $field_name = 'field_' . strtolower($this->randomName());
+    $field_name = 'field_' . strtolower($this->randomSafeString());
     $this->createFileField($field_name, $type_name);
     $field = field_info_field($field_name);
     $instance = field_info_instance('node', $field_name, $type_name);
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
index d6bcb65..96991f6 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterAdminTest.php
@@ -40,8 +40,8 @@ class FilterAdminTest extends WebTestBase {
     // Add text format.
     $this->drupalGet('admin/config/content/formats');
     $this->clickLink('Add text format');
-    $format_id = drupal_strtolower($this->randomName());
-    $name = $this->randomName();
+    $format_id = drupal_strtolower($this->randomSafeString());
+    $name = $this->randomSafeString();
     $edit = array(
       'format' => $format_id,
       'name' => $name,
@@ -163,8 +163,8 @@ class FilterAdminTest extends WebTestBase {
 
     // Add format.
     $edit = array();
-    $edit['format'] = drupal_strtolower($this->randomName());
-    $edit['name'] = $this->randomName();
+    $edit['format'] = drupal_strtolower($this->randomSafeString());
+    $edit['name'] = $this->randomSafeString();
     $edit['roles[' . DRUPAL_AUTHENTICATED_RID . ']'] = 1;
     $edit['filters[' . $second_filter . '][status]'] = TRUE;
     $edit['filters[' . $first_filter . '][status]'] = TRUE;
@@ -199,13 +199,13 @@ class FilterAdminTest extends WebTestBase {
     $this->assertRaw('<option value="' . $full . '">Full HTML</option>', t('Full HTML filter accessible.'));
 
     // Use filtered HTML and see if it removes tags that are not allowed.
-    $body = '<em>' . $this->randomName() . '</em>';
+    $body = '<em>' . $this->randomSafeString() . '</em>';
     $extra_text = 'text';
     $text = $body . '<random>' . $extra_text . '</random>';
 
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
     $edit["body[$langcode][0][value]"] = $text;
     $edit["body[$langcode][0][format]"] = $filtered;
     $this->drupalPost('node/add/page', $edit, t('Save'));
@@ -257,7 +257,7 @@ class FilterAdminTest extends WebTestBase {
   function testUrlFilterAdmin() {
     // The form does not save with an invalid filter URL length.
     $edit = array(
-      'filters[filter_url][settings][filter_url_length]' => $this->randomName(4),
+      'filters[filter_url][settings][filter_url_length]' => $this->randomSafeString(4),
     );
     $this->drupalPost('admin/config/content/formats/filtered_html', $edit, t('Save configuration'));
     $this->assertNoRaw(t('The text format %format has been updated.', array('%format' => 'Filtered HTML')));
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
index d4733bc..2eb02eb 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultFormatTest.php
@@ -26,8 +26,8 @@ class FilterDefaultFormatTest extends WebTestBase {
     $formats = array();
     for ($i = 0; $i < 2; $i++) {
       $edit = array(
-        'format' => drupal_strtolower($this->randomName()),
-        'name' => $this->randomName(),
+        'format' => drupal_strtolower($this->randomSafeString()),
+        'name' => $this->randomSafeString(),
       );
       $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
       $this->resetFilterCaches();
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
index d6a08c6..d026a48 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
@@ -42,8 +42,8 @@ class FilterFormatAccessTest extends WebTestBase {
     $formats = array();
     for ($i = 0; $i < 2; $i++) {
       $edit = array(
-        'format' => drupal_strtolower($this->randomName()),
-        'name' => $this->randomName(),
+        'format' => drupal_strtolower($this->randomSafeString()),
+        'name' => $this->randomSafeString(),
       );
       $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
       $this->resetFilterCaches();
@@ -145,8 +145,8 @@ class FilterFormatAccessTest extends WebTestBase {
     // Create node to edit.
     $this->drupalLogin($this->admin_user);
     $edit = array();
-    $edit['title'] = $this->randomName(8);
-    $edit[$body_value_key] = $this->randomName(16);
+    $edit['title'] = $this->randomSafeString(8);
+    $edit[$body_value_key] = $this->randomSafeString(16);
     $edit[$body_format_key] = $this->disallowed_format->format;
     $this->drupalPost('node/add/page', $edit, t('Save'));
     $node = $this->drupalGetNodeByTitle($edit['title']);
@@ -161,7 +161,7 @@ class FilterFormatAccessTest extends WebTestBase {
 
     // Verify that title can be changed, but preview displays original body.
     $new_edit = array();
-    $new_edit['title'] = $this->randomName(8);
+    $new_edit['title'] = $this->randomSafeString(8);
     $this->drupalPost(NULL, $new_edit, t('Preview'));
     $this->assertText($edit[$body_value_key], t('Old body found in preview.'));
 
@@ -201,7 +201,7 @@ class FilterFormatAccessTest extends WebTestBase {
     // Verify that trying to save the node without selecting a new text format
     // produces an error message, and does not result in the node being saved.
     $old_title = $new_edit['title'];
-    $new_title = $this->randomName(8);
+    $new_title = $this->randomSafeString(8);
     $edit = array('title' => $new_title);
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
     $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), t('Error message is displayed.'));
@@ -235,7 +235,7 @@ class FilterFormatAccessTest extends WebTestBase {
     // format.
     $this->drupalLogin($this->filter_admin_user);
     $old_title = $new_title;
-    $new_title = $this->randomName(8);
+    $new_title = $this->randomSafeString(8);
     $edit = array('title' => $new_title);
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
     $this->assertText(t('!name field is required.', array('!name' => t('Text format'))), t('Error message is displayed.'));
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
index 2679132..f7475af 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterHooksTest.php
@@ -32,9 +32,9 @@ class FilterHooksTest extends WebTestBase {
    */
   function testFilterHooks() {
     // Add a text format.
-    $name = $this->randomName();
+    $name = $this->randomSafeString();
     $edit = array();
-    $edit['format'] = drupal_strtolower($this->randomName());
+    $edit['format'] = drupal_strtolower($this->randomSafeString());
     $edit['name'] = $name;
     $edit['roles[' . DRUPAL_ANONYMOUS_RID . ']'] = 1;
     $this->drupalPost('admin/config/content/formats/add', $edit, t('Save configuration'));
@@ -52,9 +52,9 @@ class FilterHooksTest extends WebTestBase {
 
     // Add a new custom block.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName(8);
-    $custom_block['title'] = $this->randomName(8);
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['info'] = $this->randomSafeString(8);
+    $custom_block['title'] = $this->randomSafeString(8);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     // Use the format created.
     $custom_block['body[format]'] = $format_id;
     $this->drupalPost('admin/structure/block/add', $custom_block, t('Save block'));
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
index fa87f7c..9b71103 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterNoFormatTest.php
@@ -21,7 +21,7 @@ class FilterNoFormatTest extends WebTestBase {
   function testCheckMarkupNoFormat() {
     // Create some text. Include some HTML and line breaks, so we get a good
     // test of the filtering that is applied to it.
-    $text = "<strong>" . $this->randomName(32) . "</strong>\n\n<div>" . $this->randomName(32) . "</div>";
+    $text = "<strong>" . $this->randomSafeString(32) . "</strong>\n\n<div>" . $this->randomSafeString(32) . "</div>";
 
     // Make sure that when this text is run through check_markup() with no text
     // format, it is filtered as though it is in the fallback format.
diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
index 9daac0f..c17b6d9 100644
--- a/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
+++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
@@ -91,7 +91,7 @@ class FilterUnitTest extends UnitTestBase {
 
     // Very long string hitting PCRE limits.
     $limit = max(ini_get('pcre.backtrack_limit'), ini_get('pcre.recursion_limit'));
-    $source = $this->randomName($limit);
+    $source = $this->randomSafeString($limit);
     $result = _filter_autop($source);
     $success = $this->assertEqual($result, '<p>' . $source . "</p>\n", t('Line break filter can process very long strings.'));
     if (!$success) {
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
index e7f937d..d1a18ec 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumIndexTest.php
@@ -41,10 +41,10 @@ class ForumIndexTest extends WebTestBase {
     $tid = 1;
 
     // Create a test node.
-    $title = $this->randomName(20);
+    $title = $this->randomSafeString(20);
     $edit = array(
       "title" => $title,
-      "body[$langcode][0][value]" => $this->randomName(200),
+      "body[$langcode][0][value]" => $this->randomSafeString(200),
     );
 
     // Create the forum topic, preselecting the forum ID via a URL parameter.
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
index ae26f5c..a7e8e0f 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php
@@ -196,7 +196,7 @@ class ForumTest extends WebTestBase {
     // Test adding a comment to a forum topic.
     $node = $this->createForumTopic($this->forum, FALSE);
     $edit = array();
-    $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
+    $edit['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomSafeString();
     $this->drupalPost("node/$node->nid", $edit, t('Save'));
     $this->assertResponse(200);
 
@@ -223,7 +223,7 @@ class ForumTest extends WebTestBase {
 
     // Create an orphan forum item.
     $this->drupalLogin($this->admin_user);
-    $this->drupalPost('node/add/forum', array('title' => $this->randomName(10), 'body[' . LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomName(120)), t('Save'));
+    $this->drupalPost('node/add/forum', array('title' => $this->randomSafeString(10), 'body[' . LANGUAGE_NOT_SPECIFIED .'][0][value]' => $this->randomSafeString(120)), t('Save'));
 
     $nid_count = db_query('SELECT COUNT(nid) FROM {node}')->fetchField();
     $this->assertEqual(0, $nid_count, t('A forum node was not created when missing a forum vocabulary.'));
@@ -333,13 +333,13 @@ class ForumTest extends WebTestBase {
     $original_settings = taxonomy_vocabulary_load($vid);
 
     // Generate a random name/description.
-    $title = $this->randomName(10);
-    $description = $this->randomName(100);
+    $title = $this->randomSafeString(10);
+    $description = $this->randomSafeString(100);
 
     $edit = array(
       'name' => $title,
       'description' => $description,
-      'machine_name' => drupal_strtolower(drupal_substr($this->randomName(), 3, 9)),
+      'machine_name' => drupal_strtolower(drupal_substr($this->randomSafeString(), 3, 9)),
     );
 
     // Edit the vocabulary.
@@ -375,8 +375,8 @@ class ForumTest extends WebTestBase {
    */
   function createForum($type, $parent = 0) {
     // Generate a random name/description.
-    $name = $this->randomName(10);
-    $description = $this->randomName(100);
+    $name = $this->randomSafeString(10);
+    $description = $this->randomSafeString(100);
 
     $edit = array(
       'name' => $name,
@@ -456,8 +456,8 @@ class ForumTest extends WebTestBase {
    */
   function createForumTopic($forum, $container = FALSE) {
     // Generate a random subject/body.
-    $title = $this->randomName(20);
-    $body = $this->randomName(200);
+    $title = $this->randomSafeString(20);
+    $body = $this->randomSafeString(200);
 
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array(
@@ -552,7 +552,7 @@ class ForumTest extends WebTestBase {
       $edit = array();
       $langcode = LANGUAGE_NOT_SPECIFIED;
       $edit["title"] = 'node/' . $node->nid;
-      $edit["body[$langcode][0][value]"] = $this->randomName(256);
+      $edit["body[$langcode][0][value]"] = $this->randomSafeString(256);
       // Assume the topic is initially associated with $forum.
       $edit["taxonomy_forums[$langcode]"] = $this->root_forum['tid'];
       $edit['shadow'] = TRUE;
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
index d683720..41fe469 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageAdminStylesTest.php
@@ -64,7 +64,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
    */
   function testStyle() {
     // Setup a style to be created and effects to add to it.
-    $style_name = strtolower($this->randomName(10));
+    $style_name = strtolower($this->randomSafeString(10));
     $style_path = 'admin/config/media/image-styles/edit/' . $style_name;
     $effect_edits = array(
       'image_resize' => array(
@@ -143,7 +143,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
 
     // Test the style overview form.
     // Change the name of the style and adjust the weights of effects.
-    $style_name = strtolower($this->randomName(10));
+    $style_name = strtolower($this->randomSafeString(10));
     $weight = count($effect_edits);
     $edit = array(
       'name' => $style_name,
@@ -216,12 +216,12 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
    */
   function testStyleReplacement() {
     // Create a new style.
-    $style_name = strtolower($this->randomName(10));
+    $style_name = strtolower($this->randomSafeString(10));
     image_style_save(array('name' => $style_name));
     $style_path = 'admin/config/media/image-styles/edit/' . $style_name;
 
     // Create an image field that uses the new style.
-    $field_name = strtolower($this->randomName(10));
+    $field_name = strtolower($this->randomSafeString(10));
     $this->createImageField($field_name, 'article');
     $instance = field_info_instance('node', $field_name, 'article');
     $instance['display']['default']['type'] = 'image';
@@ -238,7 +238,7 @@ class ImageAdminStylesTest extends ImageFieldTestBase {
     $this->assertRaw(image_style_url($style_name, $node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['uri']), t('Image displayed using style @style.', array('@style' => $style_name)));
 
     // Rename the style and make sure the image field is updated.
-    $new_style_name = strtolower($this->randomName(10));
+    $new_style_name = strtolower($this->randomSafeString(10));
     $edit = array(
       'name' => $new_style_name,
     );
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
index ed5e9ab..3e37878 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
@@ -38,7 +38,7 @@ class ImageFieldDefaultImagesTest extends ImageFieldTestBase {
     }
 
     // Create an image field and add an instance to the article content type.
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $field_settings = array(
       'default_image' => $default_images['field']->fid,
     );
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
index 111c59f..d8e2839 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php
@@ -43,7 +43,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
    * Test image formatters on node display.
    */
   function _testImageFieldFormatters($scheme) {
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createImageField($field_name, 'article', array('uri_scheme' => $scheme));
     // Create a new node with an image attached.
     $test_image = current($this->drupalGetTestFiles('image'));
@@ -121,7 +121,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
   function testImageFieldSettings() {
     $test_image = current($this->drupalGetTestFiles('image'));
     list(, $test_image_extension) = explode('.', $test_image->filename);
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $instance_settings = array(
       'alt_field' => 1,
       'file_extensions' => $test_image_extension,
@@ -164,8 +164,8 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
     // Add alt/title fields to the image and verify that they are displayed.
     $image_info = array(
       'uri' => $node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['uri'],
-      'alt' => $this->randomName(),
-      'title' => $this->randomName(),
+      'alt' => $this->randomSafeString(),
+      'title' => $this->randomSafeString(),
       'width' => 40,
       'height' => 20,
     );
@@ -180,8 +180,8 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
     // Verify that alt/title longer than allowed results in a validation error.
     $test_size = 2000;
     $edit = array(
-      $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $this->randomName($test_size),
-      $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomName($test_size),
+      $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][alt]' => $this->randomSafeString($test_size),
+      $field_name . '[' . LANGUAGE_NOT_SPECIFIED . '][0][title]' => $this->randomSafeString($test_size),
     );
     $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save'));
     $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array(
@@ -199,7 +199,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
    */
   function testImageFieldDefaultImage() {
     // Create a new image field.
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $this->createImageField($field_name, 'article');
 
     // Create a new node, with no images and verify that no images are
@@ -250,7 +250,7 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
     $this->assertFalse($field['settings']['default_image'], t('Default image removed from field.'));
     // Create an image field that uses the private:// scheme and test that the
     // default image works as expected.
-    $private_field_name = strtolower($this->randomName());
+    $private_field_name = strtolower($this->randomSafeString());
     $this->createImageField($private_field_name, 'article', array('uri_scheme' => 'private'));
     // Add a default image to the new field.
     $edit = array(
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
index 51e85c6..21997d1 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldTestBase.php
@@ -107,7 +107,7 @@ class ImageFieldTestBase extends WebTestBase {
    */
   function uploadNodeImage($image, $field_name, $type) {
     $edit = array(
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
     );
     $edit['files[' . $field_name . '_' . LANGUAGE_NOT_SPECIFIED . '_0]'] = drupal_realpath($image->uri);
     $this->drupalPost('node/add/' . $type, $edit, t('Save'));
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
index 513a1a0..0d671d6 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldValidateTest.php
@@ -23,7 +23,7 @@ class ImageFieldValidateTest extends ImageFieldTestBase {
    * Test min/max resolution settings.
    */
   function testResolution() {
-    $field_name = strtolower($this->randomName());
+    $field_name = strtolower($this->randomSafeString());
     $min_resolution = 50;
     $max_resolution = 100;
     $instance_settings = array(
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php
index 715da9c..8739f67 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageBrowserDetectionUnitTest.php
@@ -119,7 +119,7 @@ class LanguageBrowserDetectionUnitTest extends UnitTestBase {
       '' => FALSE,
       'de,pl' => FALSE,
       'iecRswK4eh' => FALSE,
-      $this->randomName(10) => FALSE,
+      $this->randomSafeString(10) => FALSE,
     );
 
     foreach ($test_cases as $accept_language => $expected_result) {
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
index 7346bfc..f31f601 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageListTest.php
@@ -45,7 +45,7 @@ class LanguageListTest extends WebTestBase {
 
     // Add custom language.
     $langcode = 'xx';
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $edit = array(
       'predefined_langcode' => 'custom',
       'langcode' => $langcode,
@@ -78,7 +78,7 @@ class LanguageListTest extends WebTestBase {
     $this->clickLink(t('edit'));
     $this->assertTitle(t('Edit language | Drupal'), t('Page title is "Edit language".'));
     // Edit a language.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $edit = array(
       'name' => $name,
     );
@@ -134,7 +134,7 @@ class LanguageListTest extends WebTestBase {
     // language so we must add a new language and make it the default before
     // deleting English.
     $langcode = 'xx';
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $edit = array(
       'predefined_langcode' => 'custom',
       'langcode' => $langcode,
diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
index 137bba9..d7419ed 100644
--- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
+++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php
@@ -49,7 +49,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
   function testUrlRewritingEdgeCases() {
     // Check URL rewriting with a non-installed language.
     $non_existing = language_default();
-    $non_existing->langcode = $this->randomName();
+    $non_existing->langcode = $this->randomSafeString();
     $this->checkUrl($non_existing, t('Path language is ignored if language is not installed.'), t('URL language negotiation does not work with non-installed languages'));
   }
 
@@ -71,7 +71,7 @@ class LanguageUrlRewritingTest extends WebTestBase {
     // If the rewritten URL has not a language prefix we pick a random prefix so
     // we can always check the prefixed URL.
     $prefixes = language_negotiation_url_prefixes();
-    $stored_prefix = isset($prefixes[$language->langcode]) ? $prefixes[$language->langcode] : $this->randomName();
+    $stored_prefix = isset($prefixes[$language->langcode]) ? $prefixes[$language->langcode] : $this->randomSafeString();
     if ($this->assertNotEqual($stored_prefix, $prefix, $message1)) {
       $prefix = $stored_prefix;
     }
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php
index 9bb8bc0..2cbee35 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCommentLanguageTest.php
@@ -77,10 +77,10 @@ class LocaleCommentLanguageTest extends WebTestBase {
       $langcode_not_specified = LANGUAGE_NOT_SPECIFIED;
 
       // Create "Article" content.
-      $title = $this->randomName();
+      $title = $this->randomSafeString();
       $edit = array(
         "title" => $title,
-        "body[$langcode_not_specified][0][value]" => $this->randomName(),
+        "body[$langcode_not_specified][0][value]" => $this->randomSafeString(),
         "langcode" => $node_langcode,
       );
       $this->drupalPost("node/add/article", $edit, t('Save'));
@@ -90,7 +90,7 @@ class LocaleCommentLanguageTest extends WebTestBase {
       foreach (language_list() as $langcode => $language) {
         // Post a comment with content language $langcode.
         $prefix = empty($prefixes[$langcode]) ? '' : $prefixes[$langcode] . '/';
-        $edit = array("comment_body[$langcode_not_specified][0][value]" => $this->randomName());
+        $edit = array("comment_body[$langcode_not_specified][0][value]" => $this->randomSafeString());
         $this->drupalPost("{$prefix}node/{$node->nid}", $edit, t('Save'));
 
         // Check that comment language matches the current content language.
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
index fbedc33..5fe5a30 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
@@ -71,7 +71,7 @@ class LocaleContentTest extends WebTestBase {
     // Code for the language.
     $langcode = 'xx';
     // The English name for the language.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $edit = array(
       'predefined_langcode' => 'custom',
       'langcode' => $langcode,
@@ -104,8 +104,8 @@ class LocaleContentTest extends WebTestBase {
     $this->assertText($name, t('Language present.'));
 
     // Create "Basic page" content.
-    $node_title = $this->randomName();
-    $node_body =  $this->randomName();
+    $node_title = $this->randomSafeString();
+    $node_body =  $this->randomSafeString();
     $edit = array(
       'type' => 'page',
       'title' => $node_title,
@@ -196,8 +196,8 @@ class LocaleContentTest extends WebTestBase {
    */
   protected function createNodeArticle($langcode) {
     $this->drupalGet('node/add/article');
-    $node_title = $this->randomName();
-    $node_body =  $this->randomName();
+    $node_title = $this->randomSafeString();
+    $node_body =  $this->randomSafeString();
     $edit = array(
       'type' => 'article',
       'title' => $node_title,
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php
index 2126b26..7a9d3f4 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php
@@ -187,8 +187,8 @@ class LocaleFileImportStatus extends WebTestBase {
     variable_set('locale_translate_file_directory', $dir);
     $langcode = 'de';
     $this->addLanguage($langcode);
-    $file_uri = $dir . '/po_' . $this->randomName() . '.' . $langcode . '.po';
-    file_put_contents($file_uri, $this->randomName());
+    $file_uri = $dir . '/po_' . $this->randomSafeString() . '.' . $langcode . '.po';
+    file_put_contents($file_uri, $this->randomSafeString());
     $this->assertTrue(is_file($file_uri), 'Translation file is created.');
     language_delete($langcode);
     $this->assertTrue($file_uri);
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
index 6fe77c2..300e9a8 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php
@@ -71,7 +71,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
 
 
     // Try importing a .po file which doesn't exist.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $this->drupalPost('admin/config/regional/translate/import', array(
       'langcode' => 'fr',
       'files[file]' => $name,
@@ -183,7 +183,7 @@ class LocaleImportFunctionalTest extends WebTestBase {
     // Code for the language - manually set to match the test translation file.
     $langcode = 'xx';
     // The English name for the language.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
 
     // Create a custom language.
     $edit = array(
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
index 61fd67f..65f9ce9 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
@@ -42,7 +42,7 @@ class LocalePathTest extends WebTestBase {
     // Code for the language.
     $langcode = 'xx';
     // The English name for the language.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     // The domain prefix.
     $prefix = $langcode;
     $edit = array(
@@ -67,7 +67,7 @@ class LocalePathTest extends WebTestBase {
 
     // Create a path alias in default language (English).
     $path = 'admin/config/search/path/add';
-    $english_path = $this->randomName(8);
+    $english_path = $this->randomSafeString(8);
     $edit = array(
       'source'   => 'node/' . $node->nid,
       'alias'    => $english_path,
@@ -76,7 +76,7 @@ class LocalePathTest extends WebTestBase {
     $this->drupalPost($path, $edit, t('Save'));
 
     // Create a path alias in new custom language.
-    $custom_language_path = $this->randomName(8);
+    $custom_language_path = $this->randomSafeString(8);
     $edit = array(
       'source'   => 'node/' . $node->nid,
       'alias'    => $custom_language_path,
@@ -93,7 +93,7 @@ class LocalePathTest extends WebTestBase {
     $this->assertText($node->title, t('Custom language alias works.'));
 
     // Create a custom path.
-    $custom_path = $this->randomName(8);
+    $custom_path = $this->randomSafeString(8);
 
     // Check priority of language for alias by source path.
     $edit = array(
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
index 212f32e..4b7b86d 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationTest.php
@@ -38,13 +38,13 @@ class LocaleTranslationTest extends WebTestBase {
     // Code for the language.
     $langcode = 'xx';
     // The English name for the language. This will be translated.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     // This is the language indicator on the translation search screen for
     // untranslated strings.
     $language_indicator = "<em class=\"locale-untranslated\">$langcode</em> ";
     // This will be the translation of $name.
-    $translation = $this->randomName(16);
-    $translation_to_en = $this->randomName(16);
+    $translation = $this->randomSafeString(16);
+    $translation_to_en = $this->randomSafeString(16);
 
     // Add custom language.
     $this->drupalLogin($admin_user);
@@ -78,7 +78,7 @@ class LocaleTranslationTest extends WebTestBase {
     $textarea = current($this->xpath('//textarea'));
     $lid = (string) $textarea[0]['name'];
     $edit = array(
-      $lid => $this->randomName(),
+      $lid => $this->randomSafeString(),
     );
     // No t() here, it's surely not translated yet.
     $this->assertText($name, t('name found on edit screen.'));
@@ -198,7 +198,7 @@ class LocaleTranslationTest extends WebTestBase {
 
     $langcode = 'xx';
     // The English name for the language. This will be translated.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
 
     // Add custom language.
     $edit = array(
@@ -231,7 +231,7 @@ class LocaleTranslationTest extends WebTestBase {
     $textarea = current($this->xpath('//textarea'));
     $lid = (string) $textarea[0]['name'];
     $edit = array(
-      $lid => $this->randomName(),
+      $lid => $this->randomSafeString(),
     );
     $this->drupalPost('admin/config/regional/translate/translate', $edit, t('Save translations'));
 
@@ -261,16 +261,16 @@ class LocaleTranslationTest extends WebTestBase {
     $this->drupalLogin($admin_user);
     $langcode = 'xx';
     // The English name for the language. This will be translated.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
 
     // These will be the invalid translations of $name.
-    $key = $this->randomName(16);
+    $key = $this->randomSafeString(16);
     $bad_translations[$key] = "<script>alert('xss');</script>" . $key;
-    $key = $this->randomName(16);
+    $key = $this->randomSafeString(16);
     $bad_translations[$key] = '<img SRC="javascript:alert(\'xss\');">' . $key;
-    $key = $this->randomName(16);
+    $key = $this->randomSafeString(16);
     $bad_translations[$key] = '<<SCRIPT>alert("xss");//<</SCRIPT>' . $key;
-    $key = $this->randomName(16);
+    $key = $this->randomSafeString(16);
     $bad_translations[$key] ="<BODY ONLOAD=alert('xss')>" . $key;
 
     // Add custom language.
@@ -320,12 +320,12 @@ class LocaleTranslationTest extends WebTestBase {
     // Code for the language.
     $langcode = 'xx';
     // The English name for the language. This will be translated.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     // This is the language indicator on the translation search screen for
     // untranslated strings.
     $language_indicator = "<em class=\"locale-untranslated\">$langcode</em> ";
     // This will be the translation of $name.
-    $translation = $this->randomName(16);
+    $translation = $this->randomSafeString(16);
 
     // Add custom language.
     $this->drupalLogin($admin_user);
@@ -340,7 +340,7 @@ class LocaleTranslationTest extends WebTestBase {
     $edit = array(
       'predefined_langcode' => 'custom',
       'langcode' => 'yy',
-      'name' => $this->randomName(16),
+      'name' => $this->randomSafeString(16),
       'direction' => '0',
     );
     $this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
@@ -443,7 +443,7 @@ class LocaleTranslationTest extends WebTestBase {
     $this->assertText(t('No strings available.'), t("Search didn't find the translation."));
 
     // Search for a string that isn't in the system.
-    $unavailable_string = $this->randomName(16);
+    $unavailable_string = $this->randomSafeString(16);
     $search = array(
       'string' => $unavailable_string,
       'langcode' => $langcode,
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
index 28ca832..706b702 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
@@ -54,11 +54,11 @@ class MenuNodeTest extends WebTestBase {
     $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
 
     // Create a node.
-    $node_title = $this->randomName();
+    $node_title = $this->randomSafeString();
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array(
       "title" => $node_title,
-      "body[$langcode][0][value]" => $this->randomString(),
+      "body[$langcode][0][value]" => $this->randomUnsafeString(),
     );
     $this->drupalPost('node/add/page', $edit, t('Save'));
     $node = $this->drupalGetNodeByTitle($node_title);
@@ -101,7 +101,7 @@ class MenuNodeTest extends WebTestBase {
     // Add a menu link to the Management menu.
     $item = array(
       'link_path' => 'node/' . $node->nid,
-      'link_title' => $this->randomName(16),
+      'link_title' => $this->randomSafeString(16),
       'menu_name' => 'management',
     );
     menu_link_save($item);
@@ -122,7 +122,7 @@ class MenuNodeTest extends WebTestBase {
     // Assign a menu link to the second node, being a child of the first one.
     $child_item = array(
       'link_path' => 'node/'. $child_node->nid,
-      'link_title' => $this->randomName(16),
+      'link_title' => $this->randomSafeString(16),
       'plid' => $item['mlid'],
     );
     menu_link_save($child_item);
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
index 4cdf809..40e5251 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -72,7 +72,7 @@ class MenuTest extends WebTestBase {
     $this->modifyMenuLink($item);
     $item = menu_link_load($item['mlid']);
     // Verify that a change to the description is saved.
-    $description = $this->randomName(16);
+    $description = $this->randomSafeString(16);
     $item['options']['attributes']['title']  = $description;
     menu_link_save($item);
     $saved_item = menu_link_load($item['mlid']);
@@ -105,8 +105,8 @@ class MenuTest extends WebTestBase {
    */
   function addCustomMenuCRUD() {
     // Add a new custom menu.
-    $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
-    $title = $this->randomName(16);
+    $menu_name = substr(hash('sha256', $this->randomSafeString(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
+    $title = $this->randomSafeString(16);
 
     $menu = array(
       'menu_name' => $menu_name,
@@ -120,7 +120,7 @@ class MenuTest extends WebTestBase {
     $this->assertRaw($title, t('Custom menu was added.'));
 
     // Edit the menu.
-    $new_title = $this->randomName(16);
+    $new_title = $this->randomSafeString(16);
     $menu['title'] = $new_title;
     menu_save($menu);
     $this->drupalGet('admin/structure/menu/manage/' . $menu_name . '/edit');
@@ -135,8 +135,8 @@ class MenuTest extends WebTestBase {
 
     // Try adding a menu using a menu_name that is too long.
     $this->drupalGet('admin/structure/menu/add');
-    $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI + 1);
-    $title = $this->randomName(16);
+    $menu_name = substr(hash('sha256', $this->randomSafeString(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI + 1);
+    $title = $this->randomSafeString(16);
     $edit = array(
       'menu_name' => $menu_name,
       'description' => '',
@@ -152,7 +152,7 @@ class MenuTest extends WebTestBase {
     )));
 
     // Change the menu_name so it no longer exceeds the maximum length.
-    $menu_name = substr(hash('sha256', $this->randomName(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
+    $menu_name = substr(hash('sha256', $this->randomSafeString(16)), 0, MENU_MAX_MENU_NAME_LENGTH_UI);
     $edit['menu_name'] = $menu_name;
     $this->drupalPost('admin/structure/menu/add', $edit, t('Save'));
 
@@ -294,7 +294,7 @@ class MenuTest extends WebTestBase {
     $this->drupalGet("admin/structure/menu/manage/$menu_name/add");
     $this->assertResponse(200);
 
-    $title = '!link_' . $this->randomName(16);
+    $title = '!link_' . $this->randomSafeString(16);
     $edit = array(
       'link_path' => $link,
       'link_title' => $title,
@@ -388,7 +388,7 @@ class MenuTest extends WebTestBase {
    * @param array $item Menu link passed by reference.
    */
   function modifyMenuLink(&$item) {
-    $item['link_title'] = $this->randomName(16);
+    $item['link_title'] = $this->randomSafeString(16);
 
     $mlid = $item['mlid'];
     $title = $item['link_title'];
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
index cc7d792..a39d68a 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -29,7 +29,7 @@ class NodeAccessFieldTest extends NodeTestBase {
     $this->content_admin_user = $this->drupalCreateUser(array('access content', 'administer content types'));
 
     // Add a custom field to the page content type.
-    $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $this->field = field_create_field(array('field_name' => $this->field_name, 'type' => 'text'));
     $this->instance = field_create_instance(array(
       'field_name' => $this->field_name,
@@ -45,7 +45,7 @@ class NodeAccessFieldTest extends NodeTestBase {
     // Create a page node.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $field_data = array();
-    $value = $field_data[$langcode][0]['value'] = $this->randomName();
+    $value = $field_data[$langcode][0]['value'] = $this->randomSafeString();
     $node = $this->drupalCreateNode(array($this->field_name => $field_data));
 
     // Log in as the administrator and confirm that the field value is present.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
index 1d2c588..9e8a7e3 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
@@ -39,10 +39,10 @@ class NodeAccessPagerTest extends WebTestBase {
     for ($i = 0; $i < 60; $i++) {
       $comment = entity_create('comment', array(
         'nid' => $node->nid,
-        'subject' => $this->randomName(),
+        'subject' => $this->randomSafeString(),
         'comment_body' => array(
           LANGUAGE_NOT_SPECIFIED => array(
-            array('value' => $this->randomName()),
+            array('value' => $this->randomSafeString()),
           ),
         ),
       ));
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
index d89100d..10dae3b 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
@@ -39,7 +39,7 @@ class NodeAdminTest extends NodeTestBase {
   function testContentAdminSort() {
     $this->drupalLogin($this->admin_user);
     foreach (array('dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB') as $prefix) {
-      $this->drupalCreateNode(array('title' => $prefix . $this->randomName(6)));
+      $this->drupalCreateNode(array('title' => $prefix . $this->randomSafeString(6)));
     }
 
     // Test that the default sort by node.changed DESC actually fires properly.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
index abfcbdd..8e310db 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
@@ -47,7 +47,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
 
     // Set block title and variables.
     $block = array(
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
       'node_recent_block_count' => 2,
     );
     $this->drupalPost('admin/structure/block/manage/node/recent/configure', $block, t('Save block'));
@@ -116,10 +116,10 @@ class NodeBlockFunctionalTest extends NodeTestBase {
 
     // Create the custom block.
     $custom_block = array();
-    $custom_block['info'] = $this->randomName();
-    $custom_block['title'] = $this->randomName();
+    $custom_block['info'] = $this->randomSafeString();
+    $custom_block['title'] = $this->randomSafeString();
     $custom_block['types[article]'] = TRUE;
-    $custom_block['body[value]'] = $this->randomName(32);
+    $custom_block['body[value]'] = $this->randomSafeString(32);
     $custom_block['regions[' . variable_get('theme_default', 'stark') . ']'] = 'content';
     if ($admin_theme = variable_get('admin_theme')) {
       $custom_block['regions[' . $admin_theme . ']'] = 'content';
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockTest.php
index 3a72293..1cc74bb 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockTest.php
@@ -26,7 +26,7 @@ class NodeBlockTest extends NodeTestBase {
 
   function testSearchFormBlock() {
     // Set block title to confirm that the interface is available.
-    $this->drupalPost('admin/structure/block/manage/node/syndicate/configure', array('title' => $this->randomName(8)), t('Save block'));
+    $this->drupalPost('admin/structure/block/manage/node/syndicate/configure', array('title' => $this->randomSafeString(8)), t('Save block'));
     $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
 
     // Set the block to a region to confirm block is available.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBuildContentTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBuildContentTest.php
index 2b0dbeb..00b9ce4 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBuildContentTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBuildContentTest.php
@@ -27,7 +27,7 @@ class NodeBuildContentTest extends NodeTestBase {
     $node = $this->drupalCreateNode();
 
     // Set a property in the content array so we can test for its existence later on.
-    $node->content['test_content_property'] = array('#value' => $this->randomString());
+    $node->content['test_content_property'] = array('#value' => $this->randomUnsafeString());
     $content = node_build_content($node);
 
     // If the property doesn't exist it means the node->content was rebuilt.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index f66b2ac..00f02e9 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
@@ -34,8 +34,8 @@ class NodeCreationTest extends NodeTestBase {
     // Create a node.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName(8);
-    $edit["body[$langcode][0][value]"] = $this->randomName(16);
+    $edit["title"] = $this->randomSafeString(8);
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Save'));
 
     // Check that the Basic page has been created.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
index 5e3f0b8..40ac409 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityFieldQueryAlterTest.php
@@ -40,7 +40,7 @@ class NodeEntityFieldQueryAlterTest extends NodeTestBase {
     $settings = array('langcode' => LANGUAGE_NOT_SPECIFIED);
     for ($i = 0; $i < 4; $i++) {
       $body = array(
-        'value' => 'A' . $this->randomName(32),
+        'value' => 'A' . $this->randomSafeString(32),
         'format' => filter_default_format(),
       );
       $settings['body'][LANGUAGE_NOT_SPECIFIED][0] = $body;
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
index df1ce3e..2876104 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
@@ -62,9 +62,9 @@ class NodeFieldMultilingualTestCase extends WebTestBase {
     // Create "Basic page" content.
     $langcode = node_type_get_default_langcode('page');
     $title_key = "title";
-    $title_value = $this->randomName(8);
+    $title_value = $this->randomSafeString(8);
     $body_key = "body[$langcode][0][value]";
-    $body_value = $this->randomName(16);
+    $body_value = $this->randomSafeString(16);
 
     // Create node to edit.
     $edit = array();
@@ -82,7 +82,7 @@ class NodeFieldMultilingualTestCase extends WebTestBase {
     // Change node language.
     $this->drupalGet("node/$node->nid/edit");
     $edit = array(
-      $title_key => $this->randomName(8),
+      $title_key => $this->randomSafeString(8),
       'langcode' => 'it'
     );
     $this->drupalPost(NULL, $edit, t('Save'));
@@ -110,9 +110,9 @@ class NodeFieldMultilingualTestCase extends WebTestBase {
     // Create "Basic page" content.
     $langcode = node_type_get_default_langcode('page');
     $title_key = "title";
-    $title_value = $this->randomName(8);
+    $title_value = $this->randomSafeString(8);
     $body_key = "body[$langcode][0][value]";
-    $body_value = $this->randomName(16);
+    $body_value = $this->randomSafeString(16);
 
     // Create node to edit.
     $edit = array();
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
index 9ce688a..95d5be8 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodePostSettingsTest.php
@@ -39,8 +39,8 @@ class NodePostSettingsTest extends NodeTestBase {
     // Create a node.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName(8);
-    $edit["body[$langcode][0][value]"] = $this->randomName(16);
+    $edit["title"] = $this->randomSafeString(8);
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Save'));
 
     // Check that the post information is displayed.
@@ -62,8 +62,8 @@ class NodePostSettingsTest extends NodeTestBase {
     // Create a node.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName(8);
-    $edit["body[$langcode][0][value]"] = $this->randomName(16);
+    $edit["title"] = $this->randomSafeString(8);
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Save'));
 
     // Check that the post information is displayed.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
index 7156e10..fc8b42f 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
@@ -40,7 +40,7 @@ class NodeRevisionPermissionsTest extends NodeTestBase {
       // Create a revision for the same nid and settings with a random log.
       $revision = clone $node;
       $revision->revision = 1;
-      $revision->log = $this->randomName(32);
+      $revision->log = $this->randomSafeString(32);
       node_save($revision);
       $this->node_revisions[] = $revision;
     }
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
index 3cba15d..7eb1407 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
@@ -41,7 +41,7 @@ class NodeRevisionsTest extends NodeTestBase {
     // Create three revisions.
     $revision_count = 3;
     for ($i = 0; $i < $revision_count; $i++) {
-      $logs[] = $settings['log'] = $this->randomName(32);
+      $logs[] = $settings['log'] = $this->randomSafeString(32);
 
       // Create revision with random title and body and update variables.
       $this->drupalCreateNode($settings);
@@ -119,14 +119,14 @@ class NodeRevisionsTest extends NodeTestBase {
    */
   function testNodeRevisionWithoutLogMessage() {
     // Create a node with an initial log message.
-    $log = $this->randomName(10);
+    $log = $this->randomSafeString(10);
     $node = $this->drupalCreateNode(array('log' => $log));
 
     // Save over the same revision and explicitly provide an empty log message
     // (for example, to mimic the case of a node form submitted with no text in
     // the "log message" field), and check that the original log message is
     // preserved.
-    $new_title = $this->randomName(10) . 'testNodeRevisionWithoutLogMessage1';
+    $new_title = $this->randomSafeString(10) . 'testNodeRevisionWithoutLogMessage1';
 
     $node = clone $node;
     $node->title = $new_title;
@@ -144,7 +144,7 @@ class NodeRevisionsTest extends NodeTestBase {
 
     // Save a new node revision without providing a log message, and check that
     // this revision has an empty log message.
-    $new_title = $this->randomName(10) . 'testNodeRevisionWithoutLogMessage2';
+    $new_title = $this->randomSafeString(10) . 'testNodeRevisionWithoutLogMessage2';
 
     $node = clone $node;
     $node->title = $new_title;
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
index 3bf6a19..f79bb35 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
@@ -39,10 +39,10 @@ class NodeSaveTest extends NodeTestBase {
     // Node ID must be a number that is not in the database.
     $max_nid = db_query('SELECT MAX(nid) FROM {node}')->fetchField();
     $test_nid = $max_nid + mt_rand(1000, 1000000);
-    $title = $this->randomName(8);
+    $title = $this->randomSafeString(8);
     $node = array(
       'title' => $title,
-      'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32)))),
+      'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomSafeString(32)))),
       'uid' => $this->web_user->uid,
       'type' => 'article',
       'nid' => $test_nid,
@@ -71,7 +71,7 @@ class NodeSaveTest extends NodeTestBase {
     $edit = array(
       'uid' => $this->web_user->uid,
       'type' => 'article',
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
     );
 
     entity_create('node', $edit)->save();
@@ -99,7 +99,7 @@ class NodeSaveTest extends NodeTestBase {
     $edit = array(
       'uid' => $this->web_user->uid,
       'type' => 'article',
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
       'changed' => 979534800, // Drupal 1.0 release.
     );
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
index a195731..4027631 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
@@ -34,7 +34,7 @@ class NodeTitleTest extends NodeTestBase {
     // Create "Basic page" content with title.
     // Add the node to the frontpage so we can test if teaser links are clickable.
     $settings = array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'promote' => 1,
     );
     $node = $this->drupalCreateNode($settings);
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
index 610c41f..b35271f 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
@@ -22,7 +22,7 @@ class NodeTitleXSSTest extends NodeTestBase {
     $this->drupalLogin($web_user);
 
     $xss = '<script>alert("xss")</script>';
-    $title = $xss . $this->randomName();
+    $title = $xss . $this->randomSafeString();
     $edit = array("title" => $title);
 
     $this->drupalPost('node/add/page', $edit, t('Preview'));
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
index 9d98550..22edec9 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -35,7 +35,7 @@ class NodeTokenReplaceTest extends NodeTestBase {
       'type' => 'article',
       'uid' => $account->uid,
       'title' => '<blink>Blinking Text</blink>',
-      'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(32), 'summary' => $this->randomName(16)))),
+      'body' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomSafeString(32), 'summary' => $this->randomSafeString(16)))),
     );
     $node = $this->drupalCreateNode($settings);
 
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php
index b02bf7d..6731b98 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypePersistenceTest.php
@@ -41,7 +41,7 @@ class NodeTypePersistenceTest extends NodeTestBase {
     $this->assertText('poll', t('poll type is found on node/add'));
 
     // Customize poll description.
-    $description = $this->randomName();
+    $description = $this->randomSafeString();
     $edit = array('description' => $description);
     $this->drupalPost('admin/structure/types/manage/poll', $edit, t('Save content type'));
 
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
index 9fa1061..43ef633 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
@@ -37,8 +37,8 @@ class PageEditTest extends NodeTestBase {
     $body_key = "body[$langcode][0][value]";
     // Create node to edit.
     $edit = array();
-    $edit[$title_key] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
+    $edit[$title_key] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Save'));
 
     // Check that the node exists in the database.
@@ -60,8 +60,8 @@ class PageEditTest extends NodeTestBase {
 
     // Edit the content of the node.
     $edit = array();
-    $edit[$title_key] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
+    $edit[$title_key] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
     // Stay on the current page, without reloading.
     $this->drupalPost(NULL, $edit, t('Save'));
 
@@ -75,8 +75,8 @@ class PageEditTest extends NodeTestBase {
     // Edit the same node, creating a new revision.
     $this->drupalGet("node/$node->nid/edit");
     $edit = array();
-    $edit['title'] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
+    $edit['title'] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
     $edit['revision'] = TRUE;
     $this->drupalPost(NULL, $edit, t('Save'));
 
@@ -103,8 +103,8 @@ class PageEditTest extends NodeTestBase {
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $body_key = "body[$langcode][0][value]";
     $edit = array();
-    $edit['title'] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
+    $edit['title'] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Save'));
 
     // Check that the node was authored by the currently logged in user.
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index 5bfd342..11330be 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -33,8 +33,8 @@ class PagePreviewTest extends NodeTestBase {
 
     // Fill in node creation form and preview node.
     $edit = array();
-    $edit[$title_key] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
+    $edit[$title_key] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
     $this->drupalPost('node/add/page', $edit, t('Preview'));
 
     // Check that the preview is displaying the title and body.
@@ -59,9 +59,9 @@ class PagePreviewTest extends NodeTestBase {
 
     // Fill in node creation form and preview node.
     $edit = array();
-    $edit[$title_key] = $this->randomName(8);
-    $edit[$body_key] = $this->randomName(16);
-    $edit['log'] = $this->randomName(32);
+    $edit[$title_key] = $this->randomSafeString(8);
+    $edit[$body_key] = $this->randomSafeString(16);
+    $edit['log'] = $this->randomSafeString(32);
     $this->drupalPost('node/add/page', $edit, t('Preview'));
 
     // Check that the preview is displaying the title and body.
diff --git a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
index edf7fd8..e38da4d 100644
--- a/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
+++ b/core/modules/openid/lib/Drupal/openid/Tests/OpenIDFunctionalTest.php
@@ -64,7 +64,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase {
     // "http://specs.openid.net/auth/2.0/identifier_select" as Claimed
     // Identifier. The OpenID Provider responds with the actual identifier
     // including the fragment.
-    $identity = url('openid-test/yadis/xrds/dummy-user', array('absolute' => TRUE, 'fragment' => $this->randomName()));
+    $identity = url('openid-test/yadis/xrds/dummy-user', array('absolute' => TRUE, 'fragment' => $this->randomSafeString()));
     // Tell openid_test.module to respond with this identifier. If the fragment
     // part is present in the identifier, it should be retained.
     variable_set('openid_test_response', array('openid.claimed_id' => $identity));
@@ -167,7 +167,7 @@ class OpenIDFunctionalTest extends OpenIDTestBase {
     $this->drupalLogout();
 
     // Tell openid_test.module to alter the checkid_setup request.
-    $new_identity = 'http://example.com/' . $this->randomName();
+    $new_identity = 'http://example.com/' . $this->randomSafeString();
     variable_set('openid_test_identity', $new_identity);
     variable_set('openid_test_request_alter', array('checkid_setup' => array('openid.identity' => $new_identity)));
     $this->submitLoginForm($identity);
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
index af8b0c7..b4ca9b2 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
@@ -37,7 +37,7 @@ class PathAliasTest extends PathTestBase {
     // Create alias.
     $edit = array();
     $edit['source'] = 'node/' . $node1->nid;
-    $edit['alias'] = $this->randomName(8);
+    $edit['alias'] = $this->randomSafeString(8);
     $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
 
     // Visit the system path for the node and confirm a cache entry is
@@ -62,7 +62,7 @@ class PathAliasTest extends PathTestBase {
     // Create alias.
     $edit = array();
     $edit['source'] = 'node/' . $node1->nid;
-    $edit['alias'] = $this->randomName(8);
+    $edit['alias'] = $this->randomSafeString(8);
     $this->drupalPost('admin/config/search/path/add', $edit, t('Save'));
 
     // Confirm that the alias works.
@@ -113,7 +113,7 @@ class PathAliasTest extends PathTestBase {
     // Create a really long alias.
     $edit = array();
     $edit['source'] = 'node/' . $node1->nid;
-    $alias = $this->randomName(128);
+    $alias = $this->randomSafeString(128);
     $edit['alias'] = $alias;
     // The alias is shortened to 50 characters counting the elipsis.
     $truncated_alias = substr($alias, 0, 47);
@@ -132,7 +132,7 @@ class PathAliasTest extends PathTestBase {
 
     // Create alias.
     $edit = array();
-    $edit['path[alias]'] = $this->randomName(8);
+    $edit['path[alias]'] = $this->randomSafeString(8);
     $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
 
     // Confirm that the alias works.
@@ -196,7 +196,7 @@ class PathAliasTest extends PathTestBase {
     // Create one node with a random alias.
     $node_one = $this->drupalCreateNode();
     $edit = array();
-    $edit['path[alias]'] = $this->randomName();
+    $edit['path[alias]'] = $this->randomSafeString();
     $this->drupalPost('node/' . $node_one->nid . '/edit', $edit, t('Save'));
 
     // Now create another node and try to set the same alias.
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index b3dba0e..11627e9 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -46,7 +46,7 @@ class PathLanguageTest extends PathTestBase {
     variable_set('node_type_language_translation_enabled_page', TRUE);
 
     $english_node = $this->drupalCreateNode(array('type' => 'page'));
-    $english_alias = $this->randomName();
+    $english_alias = $this->randomSafeString();
 
     // Edit the node to set language and path.
     $edit = array();
@@ -63,9 +63,9 @@ class PathLanguageTest extends PathTestBase {
     $this->clickLink(t('add translation'));
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
-    $french_alias = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
+    $french_alias = $this->randomSafeString();
     $edit['path[alias]'] = $french_alias;
     $this->drupalPost(NULL, $edit, t('Save'));
 
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
index f1f56d6..b0a1684 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageUiTest.php
@@ -41,7 +41,7 @@ class PathLanguageUiTest extends PathTestBase {
    * Tests that a language-neutral URL alias works.
    */
   function testLanguageNeutralUrl() {
-    $name = $this->randomName(8);
+    $name = $this->randomSafeString(8);
     $edit = array();
     $edit['source'] = 'admin/config/search/path';
     $edit['alias'] = $name;
@@ -55,7 +55,7 @@ class PathLanguageUiTest extends PathTestBase {
    * Tests that a default language URL alias works.
    */
   function testDefaultLanguageUrl() {
-    $name = $this->randomName(8);
+    $name = $this->randomSafeString(8);
     $edit = array();
     $edit['source'] = 'admin/config/search/path';
     $edit['alias'] = $name;
@@ -70,7 +70,7 @@ class PathLanguageUiTest extends PathTestBase {
    * Tests that a non-default language URL alias works.
    */
   function testNonDefaultUrl() {
-    $name = $this->randomName(8);
+    $name = $this->randomSafeString(8);
     $edit = array();
     $edit['source'] = 'admin/config/search/path';
     $edit['alias'] = $name;
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
index fffb7ea..777c6d6 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathTaxonomyTermTest.php
@@ -40,11 +40,11 @@ class PathTaxonomyTermTest extends PathTestBase {
   function testTermAlias() {
     // Create a term in the default 'Tags' vocabulary with URL alias.
     $vocabulary = taxonomy_vocabulary_load(1);
-    $description = $this->randomName();;
+    $description = $this->randomSafeString();;
     $edit = array();
-    $edit['name'] = $this->randomName();
+    $edit['name'] = $this->randomSafeString();
     $edit['description[value]'] = $description;
-    $edit['path[alias]'] = $this->randomName();
+    $edit['path[alias]'] = $this->randomSafeString();
     $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
 
     // Confirm that the alias works.
@@ -54,7 +54,7 @@ class PathTaxonomyTermTest extends PathTestBase {
     // Change the term's URL alias.
     $tid = db_query("SELECT tid FROM {taxonomy_term_data} WHERE name = :name", array(':name' => $edit['name']))->fetchField();
     $edit2 = array();
-    $edit2['path[alias]'] = $this->randomName();
+    $edit2['path[alias]'] = $this->randomSafeString();
     $this->drupalPost('taxonomy/term/' . $tid . '/edit', $edit2, t('Save'));
 
     // Confirm that the changed alias works.
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php
index 6538015..7a8109a 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollBlockTest.php
@@ -26,7 +26,7 @@ class PollBlockTest extends PollTestBase {
 
   function testRecentBlock() {
     // Set block title to confirm that the interface is available.
-    $this->drupalPost('admin/structure/block/manage/poll/recent/configure', array('title' => $this->randomName(8)), t('Save block'));
+    $this->drupalPost('admin/structure/block/manage/poll/recent/configure', array('title' => $this->randomSafeString(8)), t('Save block'));
     $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
 
     // Set the block to a region to confirm block is available.
@@ -36,7 +36,7 @@ class PollBlockTest extends PollTestBase {
     $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
 
     // Create a poll which should appear in recent polls block.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(7);
     $poll_nid = $this->pollCreate($title, $choices, TRUE);
 
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php
index 9f226cb..e3797de 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollCreateTest.php
@@ -17,7 +17,7 @@ class PollCreateTest extends PollTestBase {
   }
 
   function testPollCreate() {
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(7);
     $poll_nid = $this->pollCreate($title, $choices, TRUE);
 
@@ -34,7 +34,7 @@ class PollCreateTest extends PollTestBase {
     // option is displayed.
     $node = node_load($poll_nid);
 
-    $new_option = $this->randomName();
+    $new_option = $this->randomSafeString();
 
     $vote_count = '2000';
     $node->choice[] = array(
@@ -62,7 +62,7 @@ class PollCreateTest extends PollTestBase {
     $vote_user = $this->drupalCreateUser(array('cancel own vote', 'inspect all votes', 'vote on polls', 'access content'));
 
     // Create poll.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(7);
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
 
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php
index e47ec6c..f1c9b6c 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollDeleteChoiceTest.php
@@ -18,7 +18,7 @@ class PollDeleteChoiceTest extends PollTestBase {
 
   function testChoiceRemoval() {
     // Set up a poll with three choices.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = array('First choice', 'Second choice', 'Third choice');
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
     $this->assertTrue($poll_nid, t('Poll for choice deletion logic test created.'));
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php
index f9b82e6..9508080 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php
@@ -18,7 +18,7 @@ class PollExpirationTest extends PollTestBase {
 
   function testAutoExpire() {
     // Set up a poll.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(2);
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
     $this->assertTrue($poll_nid, t('Poll for auto-expire test created.'));
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php
index 7410958..f0e8994 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollJsAddChoiceTest.php
@@ -34,9 +34,9 @@ class PollJsAddChoiceTest extends WebTestBase {
     $this->drupalLogin($web_user);
     $this->drupalGet('node/add/poll');
     $edit = array(
-      "title" => $this->randomName(),
-      'choice[new:0][chtext]' => $this->randomName(),
-      'choice[new:1][chtext]' => $this->randomName(),
+      "title" => $this->randomSafeString(),
+      'choice[new:0][chtext]' => $this->randomSafeString(),
+      'choice[new:1][chtext]' => $this->randomSafeString(),
     );
 
     // Press 'add choice' button through Ajax, and place the expected HTML result
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php
index a554dd9..2c45b68 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php
@@ -49,7 +49,7 @@ class PollTestBase extends WebTestBase {
 
     // Verify that the vote count element only allows non-negative integers.
     $edit['choice[new:1][chvotes]'] = -1;
-    $edit['choice[new:0][chvotes]'] = $this->randomString(7);
+    $edit['choice[new:0][chvotes]'] = $this->randomUnsafeString(7);
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->assertText(t('Vote count for new choice must be higher or equal to 0.'));
     $this->assertText(t('Vote count for new choice must be a number.'));
@@ -121,7 +121,7 @@ class PollTestBase extends WebTestBase {
   function _generateChoices($count = 7) {
     $choices = array();
     for ($i = 1; $i <= $count; $i++) {
-      $choices[] = $this->randomName();
+      $choices[] = $this->randomSafeString();
     }
     return $choices;
   }
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
index 3aaab13..bb6266d 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollTokenReplaceTest.php
@@ -26,7 +26,7 @@ class PollTokenReplaceTest extends PollTestBase {
     $language_interface = drupal_container()->get(LANGUAGE_TYPE_INTERFACE);
 
     // Craete a poll with three choices.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(3);
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
     $this->drupalLogout();
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php
index ee1d4d7..8639014 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollTranslateTest.php
@@ -33,8 +33,8 @@ class PollTranslateTest extends PollTestBase {
     $admin_user = $this->drupalCreateUser(array('administer content types', 'administer languages', 'edit any poll content', 'create poll content', 'administer nodes', 'translate content'));
 
     // Set up a poll with two choices.
-    $title = $this->randomName();
-    $choices = array($this->randomName(), $this->randomName());
+    $title = $this->randomSafeString();
+    $choices = array($this->randomSafeString(), $this->randomSafeString());
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
     $this->assertTrue($poll_nid, t('Poll for translation logic test created.'));
 
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php
index 9357331..ae15370 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteCheckHostnameTest.php
@@ -37,7 +37,7 @@ class PollVoteCheckHostnameTest extends PollTestBase {
     $config->save();
 
     // Create poll.
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(3);
     $this->poll_nid = $this->pollCreate($title, $choices, FALSE);
 
diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php
index 51fdc94..b959e04 100644
--- a/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php
+++ b/core/modules/poll/lib/Drupal/poll/Tests/PollVoteTest.php
@@ -21,7 +21,7 @@ class PollVoteTest extends PollTestBase {
   }
 
   function testPollVote() {
-    $title = $this->randomName();
+    $title = $this->randomSafeString();
     $choices = $this->_generateChoices(7);
     $poll_nid = $this->pollCreate($title, $choices, FALSE);
     $this->drupalLogout();
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
index cd22150..119150b 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php
@@ -54,8 +54,8 @@ class CommentAttributesTest extends CommentTestBase {
   public function testNumberOfCommentsRdfaMarkup() {
     // Posts 2 comments as a registered user.
     $this->drupalLogin($this->web_user);
-    $this->postComment($this->node1, $this->randomName(), $this->randomName());
-    $this->postComment($this->node1, $this->randomName(), $this->randomName());
+    $this->postComment($this->node1, $this->randomSafeString(), $this->randomSafeString());
+    $this->postComment($this->node1, $this->randomSafeString(), $this->randomSafeString());
 
     // Tests number of comments in teaser view.
     $this->drupalGet('node');
@@ -79,8 +79,8 @@ class CommentAttributesTest extends CommentTestBase {
 
     // Posts comment #1 as a registered user.
     $this->drupalLogin($this->web_user);
-    $comment1_subject = $this->randomName();
-    $comment1_body = $this->randomName();
+    $comment1_subject = $this->randomSafeString();
+    $comment1_body = $this->randomSafeString();
     $comment1 = $this->postComment($this->node1, $comment1_body, $comment1_subject);
 
     // Tests comment #1 with access to the user profile.
@@ -93,10 +93,10 @@ class CommentAttributesTest extends CommentTestBase {
     $this->_testBasicCommentRdfaMarkup($comment1);
 
     // Posts comment #2 as anonymous user.
-    $comment2_subject = $this->randomName();
-    $comment2_body = $this->randomName();
+    $comment2_subject = $this->randomSafeString();
+    $comment2_body = $this->randomSafeString();
     $anonymous_user = array();
-    $anonymous_user['name'] = $this->randomName();
+    $anonymous_user['name'] = $this->randomSafeString();
     $anonymous_user['mail'] = 'tester@simpletest.org';
     $anonymous_user['homepage'] = 'http://example.org/';
     $comment2 = $this->postComment($this->node2, $comment2_body, $comment2_subject, $anonymous_user);
@@ -129,7 +129,7 @@ class CommentAttributesTest extends CommentTestBase {
   public function testCommentReplyOfRdfaMarkup() {
     // Posts comment #1 as a registered user.
     $this->drupalLogin($this->web_user);
-    $comments[] = $this->postComment($this->node1, $this->randomName(), $this->randomName());
+    $comments[] = $this->postComment($this->node1, $this->randomSafeString(), $this->randomSafeString());
 
     // Tests the reply_of relationship of a first level comment.
     $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=1]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
@@ -139,7 +139,7 @@ class CommentAttributesTest extends CommentTestBase {
 
     // Posts a reply to the first comment.
     $this->drupalGet('comment/reply/' . $this->node1->nid . '/' . $comments[0]->id);
-    $comments[] = $this->postComment(NULL, $this->randomName(), $this->randomName(), TRUE);
+    $comments[] = $this->postComment(NULL, $this->randomSafeString(), $this->randomSafeString(), TRUE);
 
     // Tests the reply_of relationship of a second level comment.
     $result = $this->xpath("(id('comments')//div[contains(@class,'comment ')])[position()=2]//span[@rel='sioc:reply_of' and @resource=:node]", array(':node' => url("node/{$this->node1->nid}")));
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
index 96d2553..3e29865 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php
@@ -161,8 +161,8 @@ class RdfaMarkupTest extends WebTestBase {
     $this->assertTrue(!empty($image_rel), t('Attribute \'rel\' set on image field. Attribute \'resource\' is also set.'));
 
     // Edits the node to add tags.
-    $tag1 = $this->randomName(8);
-    $tag2 = $this->randomName(8);
+    $tag1 = $this->randomSafeString(8);
+    $tag2 = $this->randomSafeString(8);
     $edit = array();
     $edit['field_tags[' . LANGUAGE_NOT_SPECIFIED . ']'] = "$tag1, $tag2";
     $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
index fdac254..6e7d5bb 100644
--- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
+++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php
@@ -105,8 +105,8 @@ class TrackerAttributesTest extends WebTestBase {
     // Tests that the appropriate RDFa markup to annotate the latest activity
     // date has been added to the tracker output after a comment is posted.
     $comment = array(
-      'subject' => $this->randomName(),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(),
+      'subject' => $this->randomSafeString(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomSafeString(),
     );
     $this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
     $this->drupalGet('tracker');
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php
index d2eac83..44a74c4 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchBlockTest.php
@@ -26,7 +26,7 @@ class SearchBlockTest extends SearchTestBase {
 
   function testSearchFormBlock() {
     // Set block title to confirm that the interface is available.
-    $this->drupalPost('admin/structure/block/manage/search/form/configure', array('title' => $this->randomName(8)), t('Save block'));
+    $this->drupalPost('admin/structure/block/manage/search/form/configure', array('title' => $this->randomSafeString(8)), t('Save block'));
     $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
 
     // Set the block to a region to confirm block is available.
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
index ecf16d2..cc99742 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php
@@ -49,8 +49,8 @@ class SearchCommentCountToggleTest extends SearchTestBase {
 
     // Create a comment array
     $edit_comment = array();
-    $edit_comment['subject'] = $this->randomName();
-    $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomName();
+    $edit_comment['subject'] = $this->randomSafeString();
+    $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]'] = $this->randomSafeString();
     $filtered_html_format_id = 'filtered_html';
     $edit_comment['comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][format]'] = $filtered_html_format_id;
 
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
index fe9ef10..b110cc6 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchConfigSettingsFormTest.php
@@ -71,7 +71,7 @@ class SearchConfigSettingsFormTest extends SearchTestBase {
 
     // Test that the form does not save with an invalid word length.
     $edit = array(
-      'minimum_word_size' => $this->randomName(3),
+      'minimum_word_size' => $this->randomSafeString(3),
     );
     $this->drupalPost('admin/config/search/settings', $edit, t('Save configuration'));
     $this->assertNoText(t('The configuration options have been saved.'), 'Form does not save with an invalid word length.');
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
index 179b825..f919486 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchKeywordsConditionsTest.php
@@ -38,19 +38,19 @@ class SearchKeywordsConditionsTest extends SearchTestBase {
     $this->drupalGet('search/dummy_path');
     $this->assertNoText('Dummy search snippet to display');
     // With keys - get results.
-    $keys = 'bike shed ' . $this->randomName();
+    $keys = 'bike shed ' . $this->randomSafeString();
     $this->drupalGet("search/dummy_path/{$keys}");
     $this->assertText("Dummy search snippet to display. Keywords: {$keys}");
-    $keys = 'blue drop ' . $this->randomName();
+    $keys = 'blue drop ' . $this->randomSafeString();
     $this->drupalGet("search/dummy_path", array('query' => array('keys' => $keys)));
     $this->assertText("Dummy search snippet to display. Keywords: {$keys}");
     // Add some conditions and keys.
-    $keys = 'moving drop ' . $this->randomName();
+    $keys = 'moving drop ' . $this->randomSafeString();
     $this->drupalGet("search/dummy_path/bike", array('query' => array('search_conditions' => $keys)));
     $this->assertText("Dummy search snippet to display.");
     $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE));
     // Add some conditions and no keys.
-    $keys = 'drop kick ' . $this->randomName();
+    $keys = 'drop kick ' . $this->randomSafeString();
     $this->drupalGet("search/dummy_path", array('query' => array('search_conditions' => $keys)));
     $this->assertText("Dummy search snippet to display.");
     $this->assertRaw(print_r(array('search_conditions' => $keys), TRUE));
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
index 590f68b..a9dae32 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageOverrideTest.php
@@ -34,7 +34,7 @@ class SearchPageOverrideTest extends SearchTestBase {
   }
 
   function testSearchPageHook() {
-    $keys = 'bike shed ' . $this->randomName();
+    $keys = 'bike shed ' . $this->randomSafeString();
     $this->drupalGet("search/dummy_path/{$keys}");
     $this->assertText('Dummy search snippet', 'Dummy search snippet is shown');
     $this->assertText('Test page text is here', 'Page override is working');
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
index ae3ee79..bf5ace1 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchPageTextTest.php
@@ -40,7 +40,7 @@ class SearchPageTextTest extends SearchTestBase {
     $this->assertTitle($title, 'Search page title is correct');
 
     $edit = array();
-    $edit['keys'] = 'bike shed ' . $this->randomName();
+    $edit['keys'] = 'bike shed ' . $this->randomSafeString();
     $this->drupalPost('search/node', $edit, t('Search'));
     $this->assertText(t('Consider loosening your query with OR. bike OR shed will often show more results than bike shed.'), t('Help text is displayed when search returns no results.'));
     $this->assertText(t('Search'));
@@ -53,7 +53,7 @@ class SearchPageTextTest extends SearchTestBase {
 
     // Test that search keywords containing slashes are correctly loaded
     // from the path and displayed in the search form.
-    $arg = $this->randomName() . '/' . $this->randomName();
+    $arg = $this->randomSafeString() . '/' . $this->randomSafeString();
     $this->drupalGet('search/node/' . $arg);
     $input = $this->xpath("//input[@id='edit-keys' and @value='{$arg}']");
     $this->assertFalse(empty($input), 'Search keys with a / are correctly set as the default value in the search box.');
@@ -63,7 +63,7 @@ class SearchPageTextTest extends SearchTestBase {
     $limit = variable_get('search_and_or_limit', 7);
     $keys = array();
     for ($i = 0; $i < $limit + 1; $i++) {
-      $keys[] = $this->randomName(3);
+      $keys[] = $this->randomSafeString(3);
       if ($i % 2 == 0) {
         $keys[] = 'OR';
       }
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
index 278b1e0..33687c5 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
@@ -29,7 +29,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
     // Create an alias for the node so we can test aliases.
     $path = array(
       'source' => 'node/' . $this->node->nid,
-      'alias' => $this->randomName(8),
+      'alias' => $this->randomSafeString(8),
     );
     path_save($path);
 
@@ -43,7 +43,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
 
     // Check that each new shortcut links where it should.
     foreach ($test_cases as $test) {
-      $title = $this->randomName(10);
+      $title = $this->randomSafeString(10);
       $form_data = array(
         'shortcut_link[link_title]' => $title,
         'shortcut_link[link_path]'  => $test['path'],
@@ -75,7 +75,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
     $set = $this->set;
 
     // Attempt to rename shortcut link.
-    $new_link_name = $this->randomName(10);
+    $new_link_name = $this->randomSafeString(10);
 
     $this->drupalPost('admin/config/user-interface/shortcut/link/' . $set->links[0]['mlid'], array('shortcut_link[link_title]' => $new_link_name, 'shortcut_link[link_path]' => $set->links[0]['link_path']), t('Save'));
     $saved_set = shortcut_set_load($set->set_name);
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
index 8c1d9b4..607b299 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php
@@ -26,7 +26,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests creating a shortcut set.
    */
   function testShortcutSetAdd() {
-    $new_set = $this->generateShortcutSet($this->randomName(10));
+    $new_set = $this->generateShortcutSet($this->randomSafeString(10));
     $sets = shortcut_sets();
     $this->assertTrue(isset($sets[$new_set->set_name]), 'Successfully created a shortcut set.');
     $this->drupalGet('user/' . $this->admin_user->uid . '/shortcuts');
@@ -37,7 +37,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests switching a user's own shortcut set.
    */
   function testShortcutSetSwitchOwn() {
-    $new_set = $this->generateShortcutSet($this->randomName(10));
+    $new_set = $this->generateShortcutSet($this->randomSafeString(10));
 
     // Attempt to switch the default shortcut set to the newly created shortcut
     // set.
@@ -51,7 +51,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests switching another user's shortcut set.
    */
   function testShortcutSetAssign() {
-    $new_set = $this->generateShortcutSet($this->randomName(10));
+    $new_set = $this->generateShortcutSet($this->randomSafeString(10));
 
     shortcut_set_assign_user($new_set, $this->shortcut_user);
     $current_set = shortcut_current_displayed_set($this->shortcut_user);
@@ -64,7 +64,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
   function testShortcutSetSwitchCreate() {
     $edit = array(
       'set' => 'new',
-      'new' => $this->randomName(10),
+      'new' => $this->randomSafeString(10),
     );
     $this->drupalPost('user/' . $this->admin_user->uid . '/shortcuts', $edit, t('Change set'));
     $current_set = shortcut_current_displayed_set($this->admin_user);
@@ -90,7 +90,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
     $set = $this->set;
     $old_mlids = $this->getShortcutInformation($set, 'mlid');
 
-    $set->links[] = $this->generateShortcutLink('admin', $this->randomName(10));
+    $set->links[] = $this->generateShortcutLink('admin', $this->randomSafeString(10));
     shortcut_set_save($set);
     $saved_set = shortcut_set_load($set->set_name);
 
@@ -104,7 +104,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
   function testShortcutSetRename() {
     $set = $this->set;
 
-    $new_title = $this->randomName(10);
+    $new_title = $this->randomSafeString(10);
     $this->drupalPost('admin/config/user-interface/shortcut/' . $set->set_name . '/edit', array('title' => $new_title), t('Save'));
     $set = shortcut_set_load($set->set_name);
     $this->assertTrue($set->title == $new_title, 'Shortcut set has been successfully renamed.');
@@ -114,7 +114,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests renaming a shortcut set to the same name as another set.
    */
   function testShortcutSetRenameAlreadyExists() {
-    $set = $this->generateShortcutSet($this->randomName(10));
+    $set = $this->generateShortcutSet($this->randomSafeString(10));
     $existing_title = $this->set->title;
     $this->drupalPost('admin/config/user-interface/shortcut/' . $set->set_name . '/edit', array('title' => $existing_title), t('Save'));
     $this->assertRaw(t('The shortcut set %name already exists. Choose another name.', array('%name' => $existing_title)));
@@ -126,7 +126,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests unassigning a shortcut set.
    */
   function testShortcutSetUnassign() {
-    $new_set = $this->generateShortcutSet($this->randomName(10));
+    $new_set = $this->generateShortcutSet($this->randomSafeString(10));
 
     shortcut_set_assign_user($new_set, $this->shortcut_user);
     shortcut_set_unassign_user($this->shortcut_user);
@@ -139,7 +139,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
    * Tests deleting a shortcut set.
    */
   function testShortcutSetDelete() {
-    $new_set = $this->generateShortcutSet($this->randomName(10));
+    $new_set = $this->generateShortcutSet($this->randomSafeString(10));
 
     $this->drupalPost('admin/config/user-interface/shortcut/' . $new_set->set_name . '/delete', array(), t('Delete'));
     $sets = shortcut_sets();
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php
index 830bbc1..965c51c 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php
@@ -62,7 +62,7 @@ class ShortcutTestBase extends WebTestBase {
    */
   function generateShortcutSet($title = '', $default_links = TRUE) {
     $set = new stdClass();
-    $set->title = empty($title) ? $this->randomName(10) : $title;
+    $set->title = empty($title) ? $this->randomSafeString(10) : $title;
     if ($default_links) {
       $set->links = array();
       $set->links[] = $this->generateShortcutLink('node/add');
@@ -79,7 +79,7 @@ class ShortcutTestBase extends WebTestBase {
   function generateShortcutLink($path, $title = '') {
     $link = array(
       'link_path' => $path,
-      'link_title' => !empty($title) ? $title : $this->randomName(10),
+      'link_title' => !empty($title) ? $title : $this->randomSafeString(10),
     );
 
     return $link;
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 902fe6a..8766762 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
@@ -763,16 +763,23 @@ abstract class TestBase {
   /**
    * Generates a random string of ASCII characters of codes 32 to 126.
    *
-   * The generated string includes alpha-numeric characters and common misc
-   * characters. Use this method when testing general input where the content
-   * is not restricted.
+   * The generated string includes alpha-numeric characters and common
+   * miscellaneous characters. Use this method when testing general input
+   * where the content is not restricted.
+   *
+   * Do not use this method when special characters are not allowed (e.g., in
+   * machine or file names); instead, use
+   * Drupal\simpletest\TestBase::randomSafeString().
    *
    * @param $length
    *   Length of random string to generate.
+   *
    * @return
    *   Randomly generated string.
+   *
+   * @see Drupal\simpletest\TestBase::randomSafeString()
    */
-  public static function randomString($length = 8) {
+  public static function randomUnsafeString($length = 8) {
     $str = '';
     for ($i = 0; $i < $length; $i++) {
       $str .= chr(mt_rand(32, 126));
@@ -789,12 +796,18 @@ abstract class TestBase {
    * require machine readable values (i.e. without spaces and non-standard
    * characters) this method is best.
    *
+   * Do not use this method when testing unvalidated user input. Instead, use
+   * Drupal\simpletest\TestBase::randomUnsafeString().
+   *
    * @param $length
    *   Length of random string to generate.
+   *
    * @return
    *   Randomly generated string.
+   *
+   * @see Drupal\simpletest\TestBase::randomUnsafeString()
    */
-  public static function randomName($length = 8) {
+  public static function randomSafeString($length = 8) {
     $values = array_merge(range(65, 90), range(97, 122), range(48, 57));
     $max = count($values) - 1;
     $str = chr(mt_rand(97, 122));
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php
index da0fb5d..90f52cd 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php
@@ -26,8 +26,8 @@ class MailCaptureTest extends WebTestBase {
    */
   function testMailSend() {
     // Create an e-mail.
-    $subject = $this->randomString(64);
-    $body = $this->randomString(128);
+    $subject = $this->randomUnsafeString(64);
+    $body = $this->randomUnsafeString(128);
     $message = array(
       'id' => 'drupal_mail_test',
       'headers' => array('Content-type'=> 'text/html'),
@@ -58,9 +58,9 @@ class MailCaptureTest extends WebTestBase {
       $message = array(
         'id' => 'drupal_mail_test_' . $index,
         'headers' => array('Content-type'=> 'text/html'),
-        'subject' => $this->randomString(64),
-        'to' => $this->randomName(32) . '@example.com',
-        'body' => $this->randomString(512),
+        'subject' => $this->randomUnsafeString(64),
+        'to' => $this->randomSafeString(32) . '@example.com',
+        'body' => $this->randomUnsafeString(512),
       );
       drupal_mail_system('drupal_mail_test', $index)->mail($message);
     }
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index f1a5f95..7c0a93c 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -155,7 +155,7 @@ abstract class WebTestBase extends TestBase {
    * Get a node from the database based on its title.
    *
    * @param $title
-   *   A node title, usually generated by $this->randomName().
+   *   A node title, usually generated by $this->randomSafeString().
    * @param $reset
    *   (optional) Whether to reset the internal node_load() cache.
    *
@@ -182,7 +182,7 @@ abstract class WebTestBase extends TestBase {
     // Populate defaults array.
     $settings += array(
       'body'      => array(LANGUAGE_NOT_SPECIFIED => array(array())),
-      'title'     => $this->randomName(8),
+      'title'     => $this->randomSafeString(8),
       'comment'   => 2,
       'changed'   => REQUEST_TIME,
       'moderate'  => 0,
@@ -215,7 +215,7 @@ abstract class WebTestBase extends TestBase {
 
     // Merge body field value and format separately.
     $body = array(
-      'value' => $this->randomName(32),
+      'value' => $this->randomSafeString(32),
       'format' => filter_default_format(),
     );
     $settings['body'][$settings['langcode']][0] += $body;
@@ -243,7 +243,7 @@ abstract class WebTestBase extends TestBase {
   protected function drupalCreateContentType($settings = array()) {
     // Find a non-existent random type name.
     do {
-      $name = strtolower($this->randomName(8));
+      $name = strtolower($this->randomSafeString(8));
     } while (node_type_load($name));
 
     // Populate defaults array.
@@ -376,7 +376,7 @@ abstract class WebTestBase extends TestBase {
 
     // Create a user assigned to that role.
     $edit = array();
-    $edit['name']   = $this->randomName();
+    $edit['name']   = $this->randomSafeString();
     $edit['mail']   = $edit['name'] . '@example.com';
     $edit['pass']   = user_password();
     $edit['status'] = 1;
@@ -413,11 +413,11 @@ abstract class WebTestBase extends TestBase {
   protected function drupalCreateRole(array $permissions, $rid = NULL, $name = NULL) {
     // Generate a random, lowercase machine name if none was passed.
     if (!isset($rid)) {
-      $rid = strtolower($this->randomName(8));
+      $rid = strtolower($this->randomSafeString(8));
     }
     // Generate a random label.
     if (!isset($name)) {
-      $name = $this->randomString(8);
+      $name = $this->randomUnsafeString(8);
     }
 
     // Check the all the permissions strings are valid.
diff --git a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
index e0a25f9..6265079 100644
--- a/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
+++ b/core/modules/statistics/lib/Drupal/statistics/Tests/StatisticsLoggingTest.php
@@ -36,7 +36,7 @@ class StatisticsLoggingTest extends WebTestBase {
     $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));
 
     // Ensure we have a node page to access.
-    $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid));
+    $this->node = $this->drupalCreateNode(array('title' => $this->randomSafeString(255), 'uid' => $this->auth_user->uid));
 
     // Enable page caching.
     $config = config('system.performance');
@@ -118,7 +118,7 @@ class StatisticsLoggingTest extends WebTestBase {
     // (http://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits), and
     // Apache returns a 403 when testing longer file names, but the total path
     // length is not restricted.
-    $long_path = $this->randomName(127) . '/' . $this->randomName(128);
+    $long_path = $this->randomSafeString(127) . '/' . $this->randomSafeString(128);
 
     // Test that the long path is properly truncated when logged.
     $this->drupalGet($long_path);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php b/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php
index 1a31fb4..fc38e75 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Actions/ConfigurationTest.php
@@ -37,7 +37,7 @@ class ConfigurationTest extends WebTestBase {
 
     // Make a POST request to the individual action configuration page.
     $edit = array();
-    $action_label = $this->randomName();
+    $action_label = $this->randomSafeString();
     $edit['actions_label'] = $action_label;
     $edit['url'] = 'admin';
     $this->drupalPost('admin/config/system/actions/configure/' . drupal_hash_base64('system_goto_action'), $edit, t('Save'));
@@ -51,7 +51,7 @@ class ConfigurationTest extends WebTestBase {
     preg_match('|admin/config/system/actions/configure/(\d+)|', $this->getUrl(), $matches);
     $aid = $matches[1];
     $edit = array();
-    $new_action_label = $this->randomName();
+    $new_action_label = $this->randomSafeString();
     $edit['actions_label'] = $new_action_label;
     $edit['url'] = 'admin';
     $this->drupalPost(NULL, $edit, t('Save'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php
index cf77d23..5f4fcd1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Bootstrap/VariableTest.php
@@ -31,7 +31,7 @@ class VariableTest extends WebTestBase {
    */
   function testVariable() {
     // Setting and retrieving values.
-    $variable = $this->randomName();
+    $variable = $this->randomSafeString();
     variable_set('simpletest_bootstrap_variable_test', $variable);
     $this->assertIdentical($variable, variable_get('simpletest_bootstrap_variable_test'), t('Setting and retrieving values'));
 
@@ -40,7 +40,7 @@ class VariableTest extends WebTestBase {
     $this->assertText($variable, t('Variable persists across multiple requests'));
 
     // Deleting variables.
-    $default_value = $this->randomName();
+    $default_value = $this->randomSafeString();
     variable_del('simpletest_bootstrap_variable_test');
     $variable = variable_get('simpletest_bootstrap_variable_test', $default_value);
     $this->assertIdentical($variable, $default_value, t('Deleting variables'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php
index ea9b02e..077b9ec 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/ClearTest.php
@@ -21,7 +21,7 @@ class ClearTest extends CacheTestBase {
 
   function setUp() {
     $this->default_bin = 'page';
-    $this->default_value = $this->randomName(10);
+    $this->default_value = $this->randomSafeString(10);
 
     parent::setUp();
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/GetMultipleTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/GetMultipleTest.php
index f981212..2169519 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/GetMultipleTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/GetMultipleTest.php
@@ -29,8 +29,8 @@ class GetMultipleTest extends CacheTestBase {
    * Test getMultiple().
    */
   function testCacheMultiple() {
-    $item1 = $this->randomName(10);
-    $item2 = $this->randomName(10);
+    $item1 = $this->randomSafeString(10);
+    $item2 = $this->randomSafeString(10);
     $cache = cache($this->default_bin);
     $cache->set('item1', $item1);
     $cache->set('item2', $item2);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/IsEmptyTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/IsEmptyTest.php
index bd0d6ca..f498bc0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/IsEmptyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/IsEmptyTest.php
@@ -21,7 +21,7 @@ class IsEmptyTest extends CacheTestBase {
 
   function setUp() {
     $this->default_bin = 'page';
-    $this->default_value = $this->randomName(10);
+    $this->default_value = $this->randomSafeString(10);
 
     parent::setUp();
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/NullBackendTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/NullBackendTest.php
index 5a42e5d..a9dfbb1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/NullBackendTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/NullBackendTest.php
@@ -28,8 +28,8 @@ class NullBackendTest extends UnitTestBase {
   function testNullBackend() {
     $null_cache = new NullBackend('test');
 
-    $key = $this->randomName();
-    $value = $this->randomName();
+    $key = $this->randomSafeString();
+    $value = $this->randomSafeString();
 
     $null_cache->set($key, $value);
     $this->assertTrue($null_cache->isEmpty());
diff --git a/core/modules/system/lib/Drupal/system/Tests/Cache/SavingTest.php b/core/modules/system/lib/Drupal/system/Tests/Cache/SavingTest.php
index 410de25..528ca7c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Cache/SavingTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Cache/SavingTest.php
@@ -25,7 +25,7 @@ class SavingTest extends CacheTestBase {
    * Test the saving and restoring of a string.
    */
   function testString() {
-    $this->checkVariable($this->randomName(100));
+    $this->checkVariable($this->randomSafeString(100));
   }
 
   /**
@@ -54,7 +54,7 @@ class SavingTest extends CacheTestBase {
    */
   function testObject() {
     $test_object = new stdClass();
-    $test_object->test1 = $this->randomName(100);
+    $test_object->test1 = $this->randomSafeString(100);
     $test_object->test2 = 100;
     $test_object->test3 = array('drupal1', 'drupal2' => 'drupal3', 'drupal4' => array('drupal5', 'drupal6'));
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
index 8401256..44cc433 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/AddFeedTest.php
@@ -25,13 +25,13 @@ class AddFeedTest extends WebTestBase {
    * Test drupal_add_feed() with paths, URLs, and titles.
    */
   function testBasicFeedAddNoTitle() {
-    $path = $this->randomName(12);
-    $external_url = 'http://' . $this->randomName(12) . '/' . $this->randomName(12);
-    $fully_qualified_local_url = url($this->randomName(12), array('absolute' => TRUE));
+    $path = $this->randomSafeString(12);
+    $external_url = 'http://' . $this->randomSafeString(12) . '/' . $this->randomSafeString(12);
+    $fully_qualified_local_url = url($this->randomSafeString(12), array('absolute' => TRUE));
 
-    $path_for_title = $this->randomName(12);
-    $external_for_title = 'http://' . $this->randomName(12) . '/' . $this->randomName(12);
-    $fully_qualified_for_title = url($this->randomName(12), array('absolute' => TRUE));
+    $path_for_title = $this->randomSafeString(12);
+    $external_for_title = 'http://' . $this->randomSafeString(12) . '/' . $this->randomSafeString(12);
+    $fully_qualified_for_title = url($this->randomSafeString(12), array('absolute' => TRUE));
 
     // Possible permutations of drupal_add_feed() to test.
     // - 'input_url': the path passed to drupal_add_feed(),
@@ -56,17 +56,17 @@ class AddFeedTest extends WebTestBase {
       'path with title' => array(
         'input_url' => $path_for_title,
         'output_url' => url($path_for_title, array('absolute' => TRUE)),
-        'title' => $this->randomName(12),
+        'title' => $this->randomSafeString(12),
       ),
       'external url with title' => array(
         'input_url' => $external_for_title,
         'output_url' => $external_for_title,
-        'title' => $this->randomName(12),
+        'title' => $this->randomSafeString(12),
       ),
       'local url with title' => array(
         'input_url' => $fully_qualified_for_title,
         'output_url' => $fully_qualified_for_title,
-        'title' => $this->randomName(12),
+        'title' => $this->randomSafeString(12),
       ),
     );
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
index 16ffccd..88e9c48 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/GotoTest.php
@@ -65,7 +65,7 @@ class GotoTest extends WebTestBase {
    * Test drupal_get_destination().
    */
   function testDrupalGetDestination() {
-    $query = $this->randomName(10);
+    $query = $this->randomSafeString(10);
 
     // Verify that a 'destination' query string is used as destination.
     $this->drupalGet('common-test/destination', array('query' => array('destination' => $query)));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php
index 549c439..4edf5c4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/HttpRequestTest.php
@@ -69,8 +69,8 @@ class HttpRequestTest extends WebTestBase {
   }
 
   function testDrupalHTTPRequestBasicAuth() {
-    $username = $this->randomName();
-    $password = $this->randomName();
+    $username = $this->randomSafeString();
+    $password = $this->randomSafeString();
     $url = url('system-test/auth', array('absolute' => TRUE));
 
     $auth = str_replace('://', '://' . $username . ':' . $password . '@', $url);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RegionContentTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RegionContentTest.php
index 62b2ad4..7525424 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RegionContentTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RegionContentTest.php
@@ -28,13 +28,13 @@ class RegionContentTest extends WebTestBase {
     global $theme_key;
 
     $block_regions = array_keys(system_region_list($theme_key));
-    $delimiter = $this->randomName(32);
+    $delimiter = $this->randomSafeString(32);
     $values = array();
     // Set some random content for each region available.
     foreach ($block_regions as $region) {
-      $first_chunk = $this->randomName(32);
+      $first_chunk = $this->randomSafeString(32);
       drupal_add_region_content($region, $first_chunk);
-      $second_chunk = $this->randomName(32);
+      $second_chunk = $this->randomSafeString(32);
       drupal_add_region_content($region, $second_chunk);
       // Store the expected result for a drupal_get_region_content call for this region.
       $values[$region] = $first_chunk . $delimiter . $second_chunk;
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
index 90d6229..a153612 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/RenderTest.php
@@ -29,8 +29,8 @@ class RenderTest extends WebTestBase {
    * Test sorting by weight.
    */
   function testDrupalRenderSorting() {
-    $first = $this->randomName();
-    $second = $this->randomName();
+    $first = $this->randomSafeString();
+    $second = $this->randomSafeString();
     // Build an array with '#weight' set for each element.
     $elements = array(
       'second' => array(
@@ -137,8 +137,8 @@ class RenderTest extends WebTestBase {
     $this->assertEqual(drupal_render($element), 'foobar', 'Defaults work');
     $element = array(
       '#theme' => 'common_test_foo',
-      '#foo' => $this->randomName(),
-      '#bar' => $this->randomName(),
+      '#foo' => $this->randomSafeString(),
+      '#bar' => $this->randomSafeString(),
     );
     // Test that passing arguments to the theme function works.
     $this->assertEqual(drupal_render($element), $element['#foo'] . $element['#bar'], 'Passing arguments to theme functions works');
@@ -151,63 +151,63 @@ class RenderTest extends WebTestBase {
     // Define a series of form elements.
     $element = array(
       '#type' => 'button',
-      '#value' => $this->randomName(),
+      '#value' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'submit'));
 
     $element = array(
       '#type' => 'textfield',
-      '#title' => $this->randomName(),
-      '#value' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#value' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'text'));
 
     $element = array(
       '#type' => 'password',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'password'));
 
     $element = array(
       '#type' => 'textarea',
-      '#title' => $this->randomName(),
-      '#value' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#value' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//textarea');
 
     $element = array(
       '#type' => 'radio',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
       '#value' => FALSE,
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'radio'));
 
     $element = array(
       '#type' => 'checkbox',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'checkbox'));
 
     $element = array(
       '#type' => 'select',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
       '#options' => array(
-        0 => $this->randomName(),
-        1 => $this->randomName(),
+        0 => $this->randomSafeString(),
+        1 => $this->randomSafeString(),
       ),
     );
     $this->assertRenderedElement($element, '//select');
 
     $element = array(
       '#type' => 'file',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'file'));
 
     $element = array(
       '#type' => 'item',
-      '#title' => $this->randomName(),
-      '#markup' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#markup' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//div[contains(@class, :class) and contains(., :markup)]/label[contains(., :label)]', array(
       ':class' => 'form-type-item',
@@ -217,15 +217,15 @@ class RenderTest extends WebTestBase {
 
     $element = array(
       '#type' => 'hidden',
-      '#title' => $this->randomName(),
-      '#value' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#value' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//input[@type=:type]', array(':type' => 'hidden'));
 
     $element = array(
       '#type' => 'link',
-      '#title' => $this->randomName(),
-      '#href' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#href' => $this->randomSafeString(),
       '#options' => array(
         'absolute' => TRUE,
       ),
@@ -237,7 +237,7 @@ class RenderTest extends WebTestBase {
 
     $element = array(
       '#type' => 'fieldset',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//fieldset/legend[contains(., :title)]', array(
       ':title' => $element['#title'],
@@ -245,7 +245,7 @@ class RenderTest extends WebTestBase {
 
     $element = array(
       '#type' => 'fieldset',
-      '#title' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
       '#collapsible' => TRUE,
     );
     $this->assertRenderedElement($element, '//fieldset[contains(@class, :class)]', array(
@@ -254,8 +254,8 @@ class RenderTest extends WebTestBase {
 
     $element['item'] = array(
       '#type' => 'item',
-      '#title' => $this->randomName(),
-      '#markup' => $this->randomName(),
+      '#title' => $this->randomSafeString(),
+      '#markup' => $this->randomSafeString(),
     );
     $this->assertRenderedElement($element, '//fieldset/div/div[contains(@class, :class) and contains(., :markup)]', array(
       ':class' => 'form-type-item',
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
index 131ce25..9d357be 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
@@ -28,7 +28,7 @@ class UrlTest extends WebTestBase {
    * Confirm that invalid text given as $path is filtered.
    */
   function testLXSS() {
-    $text = $this->randomName();
+    $text = $this->randomSafeString();
     $path = "<SCRIPT>alert('XSS')</SCRIPT>";
     $link = l($text, $path);
     $sanitized_path = check_url(url($path));
@@ -39,7 +39,7 @@ class UrlTest extends WebTestBase {
    * Tests for active class in l() function.
    */
   function testLActiveClass() {
-    $link = l($this->randomName(), current_path());
+    $link = l($this->randomSafeString(), current_path());
     $this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active')));
   }
 
@@ -47,8 +47,8 @@ class UrlTest extends WebTestBase {
    * Tests for custom class in l() function.
    */
   function testLCustomClass() {
-    $class = $this->randomName();
-    $link = l($this->randomName(), current_path(), array('attributes' => array('class' => array($class))));
+    $class = $this->randomSafeString();
+    $link = l($this->randomSafeString(), current_path(), array('attributes' => array('class' => array($class))));
     $this->assertTrue($this->hasClass($link, $class), t('Custom class @class is present on link when requested', array('@class' => $class)));
     $this->assertTrue($this->hasClass($link, 'active'), t('Class @class is present on link to the current page', array('@class' => 'active')));
   }
@@ -196,7 +196,7 @@ class UrlTest extends WebTestBase {
 
     // Verify fragment can be overidden in an external URL.
     $url = $test_url . '#drupal';
-    $fragment = $this->randomName(10);
+    $fragment = $this->randomSafeString(10);
     $result = url($url, array('fragment' => $fragment));
     $this->assertEqual($test_url . '#' . $fragment, $result, t('External URL fragment is overidden with a custom fragment in $options.'));
 
@@ -207,13 +207,13 @@ class UrlTest extends WebTestBase {
 
     // Verify external URL can be extended with a query string.
     $url = $test_url;
-    $query = array($this->randomName(5) => $this->randomName(5));
+    $query = array($this->randomSafeString(5) => $this->randomSafeString(5));
     $result = url($url, array('query' => $query));
     $this->assertEqual($url . '?' . http_build_query($query, '', '&'), $result, t('External URL can be extended with a query string in $options.'));
 
     // Verify query string can be extended in an external URL.
     $url = $test_url . '?drupal=awesome';
-    $query = array($this->randomName(5) => $this->randomName(5));
+    $query = array($this->randomSafeString(5) => $this->randomSafeString(5));
     $result = url($url, array('query' => $query));
     $this->assertEqual($url . '&' . http_build_query($query, '', '&'), $result, t('External URL query string can be extended with a custom query string in $options.'));
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php
index 79f20a0..1fa410c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Common/WriteRecordTest.php
@@ -135,7 +135,7 @@ class WriteRecordTest extends WebTestBase {
     $node_access = new stdClass();
     $node_access->nid = mt_rand();
     $node_access->gid = mt_rand();
-    $node_access->realm = $this->randomName();
+    $node_access->realm = $this->randomSafeString();
     $insert_result = drupal_write_record('node_access', $node_access);
     $this->assertTrue($insert_result == SAVED_NEW, t('Correct value returned when a record is inserted with drupal_write_record() for a table with a multi-field primary key.'));
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/ConnectionTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/ConnectionTest.php
index 032309d..749908a 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Database/ConnectionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Database/ConnectionTest.php
@@ -46,7 +46,7 @@ class ConnectionTest extends DatabaseTestBase {
     $this->assertIdentical($db2, $db2b, t('A second call to getConnection() returns the same object.'));
 
     // Try to open an unknown target.
-    $unknown_target = $this->randomName();
+    $unknown_target = $this->randomSafeString();
     $db3 = Database::getConnection($unknown_target, 'default');
     $this->assertNotNull($db3, t('Opening an unknown target returns a real connection object.'));
     $this->assertIdentical($db1, $db3, t('An unknown target opens the default connection.'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/SelectTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/SelectTest.php
index 9c9f434..239601f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Database/SelectTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Database/SelectTest.php
@@ -302,7 +302,7 @@ class SelectTest extends DatabaseTestBase {
     // after shuffling it (in other words, nearly impossible).
     $number_of_items = 52;
     while (db_query("SELECT MAX(id) FROM {test}")->fetchField() < $number_of_items) {
-      db_insert('test')->fields(array('name' => $this->randomName()))->execute();
+      db_insert('test')->fields(array('name' => $this->randomSafeString()))->execute();
     }
 
     // First select the items in order and make sure we get an ordered list.
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/CopyTest.php b/core/modules/system/lib/Drupal/system/Tests/File/CopyTest.php
index 70f7493..67f7cc1 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/CopyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/CopyTest.php
@@ -23,9 +23,9 @@ class CopyTest extends FileHookTestBase {
    * Test file copying in the normal, base case.
    */
   function testNormal() {
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
-    $desired_uri = 'public://' . $this->randomName();
+    $desired_uri = 'public://' . $this->randomSafeString();
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
@@ -53,7 +53,7 @@ class CopyTest extends FileHookTestBase {
    */
   function testExistingRename() {
     // Setup a file to overwrite.
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
     $target = $this->createFile();
     $this->assertDifferentFile($source, $target);
@@ -93,7 +93,7 @@ class CopyTest extends FileHookTestBase {
    */
   function testExistingReplace() {
     // Setup a file to overwrite.
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
     $target = $this->createFile();
     $this->assertDifferentFile($source, $target);
@@ -131,7 +131,7 @@ class CopyTest extends FileHookTestBase {
    * specified.
    */
   function testExistingError() {
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile();
     $target = $this->createFile(NULL, $contents);
     $this->assertDifferentFile($source, $target);
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
index 5d57bdf..b3fc43f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/DirectoryTest.php
@@ -24,7 +24,7 @@ class DirectoryTest extends FileTestBase {
    */
   function testFileCheckDirectoryHandling() {
     // A directory to operate on.
-    $directory = file_default_scheme() . '://' . $this->randomName() . '/' . $this->randomName();
+    $directory = file_default_scheme() . '://' . $this->randomSafeString() . '/' . $this->randomSafeString();
     $this->assertFalse(is_dir($directory), t('Directory does not exist prior to testing.'));
 
     // Non-existent directory.
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/DownloadTest.php b/core/modules/system/lib/Drupal/system/Tests/File/DownloadTest.php
index acfa062..2923342 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/DownloadTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/DownloadTest.php
@@ -55,7 +55,7 @@ class DownloadTest extends FileTestBase {
     // Set file downloads to private so handler functions get called.
 
     // Create a file.
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
     $file = $this->createFile(NULL, $contents, 'private');
     $url  = file_create_url($file->uri);
 
@@ -75,7 +75,7 @@ class DownloadTest extends FileTestBase {
     $this->assertResponse(403, t('Correctly denied access to a file when file_test sets the header to -1.'));
 
     // Try non-existent file.
-    $url = file_create_url('private://' . $this->randomName());
+    $url = file_create_url('private://' . $this->randomSafeString());
     $this->drupalHead($url);
     $this->assertResponse(404, t('Correctly returned 404 response for a non-existent file.'));
   }
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php
index 2c72383..0889d93 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/FileTestBase.php
@@ -156,7 +156,7 @@ class FileTestBase extends WebTestBase {
   function createDirectory($path = NULL) {
     // A directory to operate on.
     if (!isset($path)) {
-      $path = file_default_scheme() . '://' . $this->randomName();
+      $path = file_default_scheme() . '://' . $this->randomSafeString();
     }
     $this->assertTrue(drupal_mkdir($path) && is_dir($path), t('Directory was created successfully.'));
     return $path;
@@ -182,7 +182,7 @@ class FileTestBase extends WebTestBase {
     if (!isset($filepath)) {
       // Prefix with non-latin characters to ensure that all file-related
       // tests work with international filenames.
-      $filepath = 'Файл для тестирования ' . $this->randomName();
+      $filepath = 'Файл для тестирования ' . $this->randomSafeString();
     }
     if (!isset($scheme)) {
       $scheme = file_default_scheme();
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/MoveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/MoveTest.php
index 64f12eb..dc93a03 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/MoveTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/MoveTest.php
@@ -23,9 +23,9 @@ class MoveTest extends FileHookTestBase {
    * Move a normal file.
    */
   function testNormal() {
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
@@ -54,7 +54,7 @@ class MoveTest extends FileHookTestBase {
    */
   function testExistingRename() {
     // Setup a file to overwrite.
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
     $target = $this->createFile();
     $this->assertDifferentFile($source, $target);
@@ -89,7 +89,7 @@ class MoveTest extends FileHookTestBase {
    */
   function testExistingReplace() {
     // Setup a file to overwrite.
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
     $target = $this->createFile();
     $this->assertDifferentFile($source, $target);
@@ -121,7 +121,7 @@ class MoveTest extends FileHookTestBase {
    */
   function testExistingReplaceSelf() {
     // Setup a file to overwrite.
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile(NULL, $contents);
 
     // Copy the file over itself. Clone the object so we don't have to worry
@@ -143,7 +143,7 @@ class MoveTest extends FileHookTestBase {
    * specified.
    */
   function testExistingError() {
-    $contents = $this->randomName(10);
+    $contents = $this->randomSafeString(10);
     $source = $this->createFile();
     $target = $this->createFile(NULL, $contents);
     $this->assertDifferentFile($source, $target);
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/NameMungingTest.php b/core/modules/system/lib/Drupal/system/Tests/File/NameMungingTest.php
index 926a34a..34bc3af 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/NameMungingTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/NameMungingTest.php
@@ -22,7 +22,7 @@ class NameMungingTest extends FileTestBase {
   function setUp() {
     parent::setUp();
     $this->bad_extension = 'php';
-    $this->name = $this->randomName() . '.' . $this->bad_extension . '.txt';
+    $this->name = $this->randomSafeString() . '.' . $this->bad_extension . '.txt';
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/SaveDataTest.php b/core/modules/system/lib/Drupal/system/Tests/File/SaveDataTest.php
index a8de40d..ab3853c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/SaveDataTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/SaveDataTest.php
@@ -23,7 +23,7 @@ class SaveDataTest extends FileHookTestBase {
    * Test the file_save_data() function when no filename is provided.
    */
   function testWithoutFilename() {
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
 
     $result = file_save_data($contents);
     $this->assertTrue($result, t('Unnamed file saved correctly.'));
@@ -45,7 +45,7 @@ class SaveDataTest extends FileHookTestBase {
    * Test the file_save_data() function when a filename is provided.
    */
   function testWithFilename() {
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
 
     // Using filename with non-latin characters.
     $filename = 'Текстовый файл.txt';
@@ -72,7 +72,7 @@ class SaveDataTest extends FileHookTestBase {
   function testExistingRename() {
     // Setup a file to overwrite.
     $existing = $this->createFile();
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
 
     $result = file_save_data($contents, $existing->uri, FILE_EXISTS_RENAME);
     $this->assertTrue($result, t("File saved successfully."));
@@ -100,7 +100,7 @@ class SaveDataTest extends FileHookTestBase {
   function testExistingReplace() {
     // Setup a file to overwrite.
     $existing = $this->createFile();
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
 
     $result = file_save_data($contents, $existing->uri, FILE_EXISTS_REPLACE);
     $this->assertTrue($result, t('File saved successfully.'));
@@ -125,7 +125,7 @@ class SaveDataTest extends FileHookTestBase {
    * Test that file_save_data() fails overwriting an existing file.
    */
   function testExistingError() {
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
     $existing = $this->createFile(NULL, $contents);
 
     // Check the overwrite error.
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/SaveUploadTest.php b/core/modules/system/lib/Drupal/system/Tests/File/SaveUploadTest.php
index 2cccaec..bd87a23 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/SaveUploadTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/SaveUploadTest.php
@@ -104,7 +104,7 @@ class SaveUploadTest extends FileHookTestBase {
     // Upload a third file to a subdirectory.
     $image3 = current($this->drupalGetTestFiles('image'));
     $image3_realpath = drupal_realpath($image3->uri);
-    $dir = $this->randomName();
+    $dir = $this->randomSafeString();
     $edit = array(
       'files[file_test_upload]' => $image3_realpath,
       'file_subdir' => $dir,
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php
index 5d5aa21..6952821 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php
@@ -27,7 +27,7 @@ class UnmanagedCopyTest extends FileTestBase {
     $file = $this->createFile();
 
     // Copying to a new name.
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
     $new_filepath = file_unmanaged_copy($file->uri, $desired_filepath, FILE_EXISTS_ERROR);
     $this->assertTrue($new_filepath, t('Copy was successful.'));
     $this->assertEqual($new_filepath, $desired_filepath, t('Returned expected filepath.'));
@@ -36,7 +36,7 @@ class UnmanagedCopyTest extends FileTestBase {
     $this->assertFilePermissions($new_filepath, variable_get('file_chmod_file', 0664));
 
     // Copying with rename.
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
     $this->assertTrue(file_put_contents($desired_filepath, ' '), t('Created a file so a rename will have to happen.'));
     $newer_filepath = file_unmanaged_copy($file->uri, $desired_filepath, FILE_EXISTS_RENAME);
     $this->assertTrue($newer_filepath, t('Copy was successful.'));
@@ -54,9 +54,9 @@ class UnmanagedCopyTest extends FileTestBase {
    */
   function testNonExistent() {
     // Copy non-existent file
-    $desired_filepath = $this->randomName();
+    $desired_filepath = $this->randomSafeString();
     $this->assertFalse(file_exists($desired_filepath), t("Randomly named file doesn't exists."));
-    $new_filepath = file_unmanaged_copy($desired_filepath, $this->randomName());
+    $new_filepath = file_unmanaged_copy($desired_filepath, $this->randomSafeString());
     $this->assertFalse($new_filepath, t('Copying a missing file fails.'));
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteRecursiveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteRecursiveTest.php
index 77fecb2..13e72af 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteRecursiveTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteRecursiveTest.php
@@ -24,7 +24,7 @@ class UnmanagedDeleteRecursiveTest extends FileTestBase {
    */
   function testSingleFile() {
     // Create a file for testing
-    $filepath = file_default_scheme() . '://' . $this->randomName();
+    $filepath = file_default_scheme() . '://' . $this->randomSafeString();
     file_put_contents($filepath, '');
 
     // Delete the file.
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteTest.php
index 326bb5b..b5557c4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedDeleteTest.php
@@ -36,7 +36,7 @@ class UnmanagedDeleteTest extends FileTestBase {
    */
   function testMissing() {
     // Try to delete a non-existing file
-    $this->assertTrue(file_unmanaged_delete(file_default_scheme() . '/' . $this->randomName()), t('Returns true when deleting a non-existent file.'));
+    $this->assertTrue(file_unmanaged_delete(file_default_scheme() . '/' . $this->randomSafeString()), t('Returns true when deleting a non-existent file.'));
   }
 
   /**
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php
index 4e5c8c4..e8f5fef 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php
@@ -27,7 +27,7 @@ class UnmanagedMoveTest extends FileTestBase {
     $file = $this->createFile();
 
     // Moving to a new name.
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
     $new_filepath = file_unmanaged_move($file->uri, $desired_filepath, FILE_EXISTS_ERROR);
     $this->assertTrue($new_filepath, t('Move was successful.'));
     $this->assertEqual($new_filepath, $desired_filepath, t('Returned expected filepath.'));
@@ -36,7 +36,7 @@ class UnmanagedMoveTest extends FileTestBase {
     $this->assertFilePermissions($new_filepath, variable_get('file_chmod_file', 0664));
 
     // Moving with rename.
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
     $this->assertTrue(file_exists($new_filepath), t('File exists before moving.'));
     $this->assertTrue(file_put_contents($desired_filepath, ' '), t('Created a file so a rename will have to happen.'));
     $newer_filepath = file_unmanaged_move($new_filepath, $desired_filepath, FILE_EXISTS_RENAME);
@@ -55,7 +55,7 @@ class UnmanagedMoveTest extends FileTestBase {
    */
   function testMissing() {
     // Move non-existent file.
-    $new_filepath = file_unmanaged_move($this->randomName(), $this->randomName());
+    $new_filepath = file_unmanaged_move($this->randomSafeString(), $this->randomSafeString());
     $this->assertFalse($new_filepath, t('Moving a missing file fails.'));
   }
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php
index 6494b86..ba493bc 100644
--- a/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/File/UnmanagedSaveDataTest.php
@@ -23,7 +23,7 @@ class UnmanagedSaveDataTest extends FileTestBase {
    * Test the file_unmanaged_save_data() function.
    */
   function testFileSaveData() {
-    $contents = $this->randomName(8);
+    $contents = $this->randomSafeString(8);
 
     // No filename.
     $filepath = file_unmanaged_save_data($contents);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsTableSelectTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsTableSelectTest.php
index 2748836..d416095 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/ElementsTableSelectTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/ElementsTableSelectTest.php
@@ -210,7 +210,7 @@ class ElementsTableSelectTest extends WebTestBase {
    *   An array containing the processed form, the form_state and any errors.
    */
   private function formSubmitHelper($form, $edit) {
-    $form_id = $this->randomName();
+    $form_id = $this->randomSafeString();
     $form_state = form_state_defaults();
 
     $form['op'] = array('#type' => 'submit', '#value' => t('Submit'));
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 20d1f56..6fdcd12 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
@@ -48,43 +48,43 @@ class FormTest extends WebTestBase {
     $empty_arrays = array('array()' => array());
     $empty_checkbox = array(NULL);
 
-    $elements['textfield']['element'] = array('#title' => $this->randomName(), '#type' => 'textfield');
+    $elements['textfield']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'textfield');
     $elements['textfield']['empty_values'] = $empty_strings;
 
-    $elements['telephone']['element'] = array('#title' => $this->randomName(), '#type' => 'tel');
+    $elements['telephone']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'tel');
     $elements['telephone']['empty_values'] = $empty_strings;
 
-    $elements['url']['element'] = array('#title' => $this->randomName(), '#type' => 'url');
+    $elements['url']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'url');
     $elements['url']['empty_values'] = $empty_strings;
 
-    $elements['search']['element'] = array('#title' => $this->randomName(), '#type' => 'search');
+    $elements['search']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'search');
     $elements['search']['empty_values'] = $empty_strings;
 
-    $elements['password']['element'] = array('#title' => $this->randomName(), '#type' => 'password');
+    $elements['password']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'password');
     $elements['password']['empty_values'] = $empty_strings;
 
-    $elements['password_confirm']['element'] = array('#title' => $this->randomName(), '#type' => 'password_confirm');
+    $elements['password_confirm']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'password_confirm');
     // Provide empty values for both password fields.
     foreach ($empty_strings as $key => $value) {
       $elements['password_confirm']['empty_values'][$key] = array('pass1' => $value, 'pass2' => $value);
     }
 
-    $elements['textarea']['element'] = array('#title' => $this->randomName(), '#type' => 'textarea');
+    $elements['textarea']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'textarea');
     $elements['textarea']['empty_values'] = $empty_strings;
 
-    $elements['radios']['element'] = array('#title' => $this->randomName(), '#type' => 'radios', '#options' => array('' => t('None'), $this->randomName(), $this->randomName(), $this->randomName()));
+    $elements['radios']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'radios', '#options' => array('' => t('None'), $this->randomSafeString(), $this->randomSafeString(), $this->randomSafeString()));
     $elements['radios']['empty_values'] = $empty_arrays;
 
-    $elements['checkbox']['element'] = array('#title' => $this->randomName(), '#type' => 'checkbox', '#required' => TRUE, '#title' => $this->randomName());
+    $elements['checkbox']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'checkbox', '#required' => TRUE, '#title' => $this->randomSafeString());
     $elements['checkbox']['empty_values'] = $empty_checkbox;
 
-    $elements['checkboxes']['element'] = array('#title' => $this->randomName(), '#type' => 'checkboxes', '#options' => array($this->randomName(), $this->randomName(), $this->randomName()));
+    $elements['checkboxes']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'checkboxes', '#options' => array($this->randomSafeString(), $this->randomSafeString(), $this->randomSafeString()));
     $elements['checkboxes']['empty_values'] = $empty_arrays;
 
-    $elements['select']['element'] = array('#title' => $this->randomName(), '#type' => 'select', '#options' => array('' => t('None'), $this->randomName(), $this->randomName(), $this->randomName()));
+    $elements['select']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'select', '#options' => array('' => t('None'), $this->randomSafeString(), $this->randomSafeString(), $this->randomSafeString()));
     $elements['select']['empty_values'] = $empty_strings;
 
-    $elements['file']['element'] = array('#title' => $this->randomName(), '#type' => 'file');
+    $elements['file']['element'] = array('#title' => $this->randomSafeString(), '#type' => 'file');
     $elements['file']['empty_values'] = $empty_strings;
 
     // Regular expression to find the expected marker on required elements.
@@ -94,7 +94,7 @@ class FormTest extends WebTestBase {
     foreach ($elements as $type => $data) {
       foreach ($data['empty_values'] as $key => $empty) {
         foreach (array(TRUE, FALSE) as $required) {
-          $form_id = $this->randomName();
+          $form_id = $this->randomSafeString();
           $form = array();
           $form_state = form_state_defaults();
           form_clear_error();
@@ -200,7 +200,7 @@ class FormTest extends WebTestBase {
     // Submit again with required fields set and verify that there are no
     // error messages.
     $edit = array(
-      'textfield' => $this->randomString(),
+      'textfield' => $this->randomUnsafeString(),
       'checkboxes[foo]' => TRUE,
       'select' => 'foo',
       'radios' => 'bar',
diff --git a/core/modules/system/lib/Drupal/system/Tests/Form/ValidationTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/ValidationTest.php
index 2386a8e..6c66e87 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/ValidationTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/ValidationTest.php
@@ -165,7 +165,7 @@ class ValidationTest extends WebTestBase {
 
     // Invalid password.
     $edit = array(
-      'password' => $this->randomName(),
+      'password' => $this->randomSafeString(),
     );
     $this->drupalPost('form-test/pattern', $edit, 'Submit');
     $this->assertNoRaw($textfield_error);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php b/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php
index ebd2a5d..5f83c68 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Image/FileMoveTest.php
@@ -40,7 +40,7 @@ class FileMoveTest extends ToolkitTestBase {
 
     // Clone the object so we don't have to worry about the function changing
     // our reference copy.
-    $desired_filepath = 'public://' . $this->randomName();
+    $desired_filepath = 'public://' . $this->randomSafeString();
     $result = file_move(clone $file, $desired_filepath, FILE_EXISTS_ERROR);
 
     // Check if image has been moved.
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 5c7e12f..f4467f4 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
@@ -190,7 +190,7 @@ class BreadcrumbTest extends MenuTestBase {
 
     foreach ($menus as $menu) {
       // Create a parent node in the current menu.
-      $title = $this->randomName();
+      $title = $this->randomSafeString();
       $node2 = $this->drupalCreateNode(array(
         'type' => $type,
         'title' => $title,
@@ -218,7 +218,7 @@ class BreadcrumbTest extends MenuTestBase {
       $this->assertBreadcrumb("node/$nid2/edit", $trail);
 
       // Create a child node in the current menu.
-      $title = $this->randomName();
+      $title = $this->randomSafeString();
       $node3 = $this->drupalCreateNode(array(
         'type' => $type,
         'title' => $title,
diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
index a3c024f..fe4d447 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TrailTest.php
@@ -126,7 +126,7 @@ class TrailTest extends MenuTestBase {
     // this test, and the expected active trail for each case.
     $paths = array(
       403 => 'admin/config',
-      404 => $this->randomName(),
+      404 => $this->randomSafeString(),
     );
     // For the 403 page, the initial trail during the Drupal bootstrap should
     // include the page that the user is trying to visit, while the final trail
diff --git a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
index 4a83d4a..23a8943 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Pager/PagerTest.php
@@ -29,7 +29,7 @@ class PagerTest extends WebTestBase {
 
     // Insert 300 log messages.
     for ($i = 0; $i < 300; $i++) {
-      watchdog('pager_test', $this->randomString(), NULL, WATCHDOG_DEBUG);
+      watchdog('pager_test', $this->randomUnsafeString(), NULL, WATCHDOG_DEBUG);
     }
 
     $this->admin_user = $this->drupalCreateUser(array(
diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/MatchPathTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/MatchPathTest.php
index db11056..55a2eed 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Path/MatchPathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Path/MatchPathTest.php
@@ -30,7 +30,7 @@ class MatchPathTest extends WebTestBase {
     parent::setUp();
 
     // Set up a random site front page to test the '<front>' placeholder.
-    $this->front = $this->randomName();
+    $this->front = $this->randomSafeString();
     variable_set('site_frontpage', $this->front);
     // Refresh our static variables from the database.
     $this->refreshVariables();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
index 9188b02..f9536ad 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Path/UrlAlterFunctionalTest.php
@@ -66,7 +66,7 @@ class UrlAlterFunctionalTest extends WebTestBase {
     $forum_vid = variable_get('forum_nav_vocabulary');
     $tid = db_insert('taxonomy_term_data')
       ->fields(array(
-        'name' => $this->randomName(),
+        'name' => $this->randomSafeString(),
         'vid' => $forum_vid,
       ))
       ->execute();
diff --git a/core/modules/system/lib/Drupal/system/Tests/Queue/QueueTest.php b/core/modules/system/lib/Drupal/system/Tests/Queue/QueueTest.php
index 9e824dc..8047090 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Queue/QueueTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Queue/QueueTest.php
@@ -28,9 +28,9 @@ class QueueTest extends WebTestBase {
    */
   public function testSystemQueue() {
     // Create two queues.
-    $queue1 = new System($this->randomName());
+    $queue1 = new System($this->randomSafeString());
     $queue1->createQueue();
-    $queue2 = new System($this->randomName());
+    $queue2 = new System($this->randomSafeString());
     $queue2->createQueue();
 
     $this->queueTest($queue1, $queue2);
@@ -41,9 +41,9 @@ class QueueTest extends WebTestBase {
    */
   public function testMemoryQueue() {
     // Create two queues.
-    $queue1 = new Memory($this->randomName());
+    $queue1 = new Memory($this->randomSafeString());
     $queue1->createQueue();
-    $queue2 = new Memory($this->randomName());
+    $queue2 = new Memory($this->randomSafeString());
     $queue2->createQueue();
 
     $this->queueTest($queue1, $queue2);
@@ -61,7 +61,7 @@ class QueueTest extends WebTestBase {
     // Create four items.
     $data = array();
     for ($i = 0; $i < 4; $i++) {
-      $data[] = array($this->randomName() => $this->randomName());
+      $data[] = array($this->randomSafeString() => $this->randomSafeString());
     }
 
     // Queue items 1 and 2 in the queue1.
diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
index 8fac3ca..09db7f2 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionHttpsTest.php
@@ -114,7 +114,7 @@ class SessionHttpsTest extends WebTestBase {
 
     $this->curlClose();
     // Start an anonymous session on the insecure site.
-    $session_data = $this->randomName();
+    $session_data = $this->randomSafeString();
     $this->drupalGet('session-test/set/' . $session_data);
     // Check secure cookie on insecure page.
     $this->assertFalse(isset($this->cookies[$secure_session_name]), 'The secure cookie is not sent on insecure pages.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
index 02cb8ae..d0813ec 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Session/SessionTest.php
@@ -82,7 +82,7 @@ class SessionTest extends WebTestBase {
 
     $this->drupalLogin($user);
 
-    $value_1 = $this->randomName();
+    $value_1 = $this->randomSafeString();
     $this->drupalGet('session-test/set/' . $value_1);
     $this->assertText($value_1, t('The session value was stored.'), t('Session'));
     $this->drupalGet('session-test/get');
@@ -90,7 +90,7 @@ class SessionTest extends WebTestBase {
 
     // Attempt to write over val_1. If drupal_save_session(FALSE) is working.
     // properly, val_1 will still be set.
-    $value_2 = $this->randomName();
+    $value_2 = $this->randomSafeString();
     $this->drupalGet('session-test/no-set/' . $value_2);
     $this->assertText($value_2, t('The session value was correctly passed to session-test/no-set.'), t('Session'));
     $this->drupalGet('session-test/get');
@@ -108,14 +108,14 @@ class SessionTest extends WebTestBase {
     $this->assertNoText($value_1, t("After logout, previous user's session data is not available."), t('Session'));
 
     // Now try to store some data as an anonymous user.
-    $value_3 = $this->randomName();
+    $value_3 = $this->randomSafeString();
     $this->drupalGet('session-test/set/' . $value_3);
     $this->assertText($value_3, t('Session data stored for anonymous user.'), t('Session'));
     $this->drupalGet('session-test/get');
     $this->assertText($value_3, t('Session correctly returned the stored data for an anonymous user.'), t('Session'));
 
     // Try to store data when drupal_save_session(FALSE).
-    $value_4 = $this->randomName();
+    $value_4 = $this->randomSafeString();
     $this->drupalGet('session-test/no-set/' . $value_4);
     $this->assertText($value_4, t('The session value was correctly passed to session-test/no-set.'), t('Session'));
     $this->drupalGet('session-test/get');
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
index 601c5a8..f75372c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/CronRunTest.php
@@ -33,7 +33,7 @@ class CronRunTest extends WebTestBase {
     $this->assertResponse(404);
 
     // Run cron anonymously with a random cron key.
-    $key = $this->randomName(16);
+    $key = $this->randomSafeString(16);
     $this->drupalGet('cron/' . $key);
     $this->assertResponse(403);
 
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
index 84bd7c6..87b9359 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/DateTimeTest.php
@@ -72,7 +72,7 @@ class DateTimeTest extends WebTestBase {
 
     // Add custom date type.
     $this->clickLink(t('Add date type'));
-    $date_type = strtolower($this->randomName(8));
+    $date_type = strtolower($this->randomSafeString(8));
     $machine_name = 'machine_' . $date_type;
     $date_format = 'd.m.Y - H:i';
     $edit = array(
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
index c8bee66..7d3bf74 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageNotFoundTest.php
@@ -32,7 +32,7 @@ class PageNotFoundTest extends WebTestBase {
 
   function testPageNotFound() {
     $this->drupalLogin($this->admin_user);
-    $this->drupalGet($this->randomName(10));
+    $this->drupalGet($this->randomSafeString(10));
     $this->assertText(t('Page not found'), t('Found the default 404 page'));
 
     // Use a custom 404 page.
@@ -41,7 +41,7 @@ class PageNotFoundTest extends WebTestBase {
     );
     $this->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
 
-    $this->drupalGet($this->randomName(10));
+    $this->drupalGet($this->randomSafeString(10));
     $this->assertText($this->admin_user->name, t('Found the custom 404 page'));
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
index 9ee0101..655ffe0 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/PageTitleFilteringTest.php
@@ -63,8 +63,8 @@ class PageTitleFilteringTest extends WebTestBase {
     // Generate node content.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array(
-      "title" => '!SimpleTest! ' . $title . $this->randomName(20),
-      "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomName(200),
+      "title" => '!SimpleTest! ' . $title . $this->randomSafeString(20),
+      "body[$langcode][0][value]" => '!SimpleTest! test body' . $this->randomSafeString(200),
     );
     // Create the node with HTML in the title.
     $this->drupalPost('node/add/page', $edit, t('Save'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/RetrieveFileTest.php b/core/modules/system/lib/Drupal/system/Tests/System/RetrieveFileTest.php
index 1c977ca..36b53ef 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/RetrieveFileTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/RetrieveFileTest.php
@@ -26,8 +26,8 @@ class RetrieveFileTest extends WebTestBase {
    */
   function testFileRetrieving() {
     // Test 404 handling by trying to fetch a randomly named file.
-    drupal_mkdir($sourcedir = 'public://' . $this->randomName());
-    $filename = 'Файл для тестирования ' . $this->randomName();
+    drupal_mkdir($sourcedir = 'public://' . $this->randomSafeString());
+    $filename = 'Файл для тестирования ' . $this->randomSafeString();
     $url = file_create_url($sourcedir . '/' . $filename);
     $retrieved_file = system_retrieve_file($url);
     $this->assertFalse($retrieved_file, t('Non-existent file not fetched.'));
@@ -46,7 +46,7 @@ class RetrieveFileTest extends WebTestBase {
     file_unmanaged_delete($retrieved_file);
 
     // Test downloading file to a different location.
-    drupal_mkdir($targetdir = 'temporary://' . $this->randomName());
+    drupal_mkdir($targetdir = 'temporary://' . $this->randomSafeString());
     $retrieved_file = system_retrieve_file($url, $targetdir);
     $this->assertEqual($retrieved_file, "$targetdir/$encoded_filename", t('Sane path for downloaded file returned (temporary:// scheme).'));
     $this->assertTrue(is_file($retrieved_file), t('Downloaded file does exist (temporary:// scheme).'));
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/ShutdownFunctionsTest.php b/core/modules/system/lib/Drupal/system/Tests/System/ShutdownFunctionsTest.php
index b38c213..57c7e5c 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/ShutdownFunctionsTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/ShutdownFunctionsTest.php
@@ -29,8 +29,8 @@ class ShutdownFunctionsTest extends WebTestBase {
    * Test shutdown functions.
    */
   function testShutdownFunctions() {
-    $arg1 = $this->randomName();
-    $arg2 = $this->randomName();
+    $arg1 = $this->randomSafeString();
+    $arg2 = $this->randomSafeString();
     $this->drupalGet('system-test/shutdown-functions/' . $arg1 . '/' . $arg2);
     $this->assertText(t('First shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
     $this->assertText(t('Second shutdown function, arg1 : @arg1, arg2: @arg2', array('@arg1' => $arg1, '@arg2' => $arg2)));
diff --git a/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php b/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php
index b006cdb..1bf5708 100644
--- a/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/System/SystemAuthorizeTest.php
@@ -50,7 +50,7 @@ class SystemAuthorizeTest extends WebTestBase {
    * Tests the FileTransfer hooks
    */
   function testFileTransferHooks() {
-    $page_title = $this->randomName(16);
+    $page_title = $this->randomSafeString(16);
     $this->drupalGetAuthorizePHP($page_title);
     $this->assertTitle(strtr('@title | Drupal', array('@title' => $page_title)), 'authorize.php page title is correct.');
     $this->assertNoText('It appears you have reached this page in error.');
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php
index 4a889cb..978eee2 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/HooksTest.php
@@ -34,7 +34,7 @@ class HooksTest extends TaxonomyTestBase {
 
     // Create a term with one antonym.
     $edit = array(
-      'name' => $this->randomName(),
+      'name' => $this->randomSafeString(),
       'antonym' => 'Long',
     );
     $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
@@ -44,7 +44,7 @@ class HooksTest extends TaxonomyTestBase {
 
     // Update the term with a different antonym.
     $edit = array(
-      'name' => $this->randomName(),
+      'name' => $this->randomSafeString(),
       'antonym' => 'Short',
     );
     $this->drupalPost('taxonomy/term/' . $term->tid . '/edit', $edit, t('Save'));
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
index d00f373..443572c 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php
@@ -35,10 +35,10 @@ class LegacyTest extends TaxonomyTestBase {
     // Posts an article with a taxonomy term and a date prior to 1970.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array();
-    $edit['title'] = $this->randomName();
+    $edit['title'] = $this->randomSafeString();
     $edit['date'] = '1969-01-01 00:00:00 -0500';
-    $edit["body[$langcode][0][value]"] = $this->randomName();
-    $edit["field_tags[$langcode]"] = $this->randomName();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
+    $edit["field_tags[$langcode]"] = $this->randomSafeString();
     $this->drupalPost('node/add/article', $edit, t('Save'));
     // Checks that the node has been saved.
     $node = $this->drupalGetNodeByTitle($edit['title']);
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
index b44f456..ec73814 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
@@ -83,7 +83,7 @@ class RssTest extends TaxonomyTestBase {
     // Post an article.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
     $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->tid;
     $this->drupalPost('node/add/article', $edit, t('Save'));
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
index b3b8760..2f8c715 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php
@@ -34,9 +34,9 @@ class TaxonomyTestBase extends WebTestBase {
   function createVocabulary() {
     // Create a vocabulary.
     $vocabulary = entity_create('taxonomy_vocabulary', array(
-      'name' => $this->randomName(),
-      'description' => $this->randomName(),
-      'machine_name' => drupal_strtolower($this->randomName()),
+      'name' => $this->randomSafeString(),
+      'description' => $this->randomSafeString(),
+      'machine_name' => drupal_strtolower($this->randomSafeString()),
       'langcode' => LANGUAGE_NOT_SPECIFIED,
       'help' => '',
       'nodes' => array('article' => 'article'),
@@ -51,8 +51,8 @@ class TaxonomyTestBase extends WebTestBase {
    */
   function createTerm($vocabulary) {
     $term = entity_create('taxonomy_term', array(
-      'name' => $this->randomName(),
-      'description' => $this->randomName(),
+      'name' => $this->randomSafeString(),
+      'description' => $this->randomSafeString(),
       // Use the first available text format.
       'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(),
       'vid' => $vocabulary->vid,
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
index 90d6cd5..2bcd458 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
@@ -33,7 +33,7 @@ class TermFieldMultipleVocabularyTest extends TaxonomyTestBase {
     $this->vocabulary2 = $this->createVocabulary();
 
     // Set up a field and instance.
-    $this->field_name = drupal_strtolower($this->randomName());
+    $this->field_name = drupal_strtolower($this->randomSafeString());
     $this->field = array(
       'field_name' => $this->field_name,
       'type' => 'taxonomy_term_reference',
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
index 37661b9..d1dfaca 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
@@ -33,7 +33,7 @@ class TermFieldTest extends TaxonomyTestBase {
     $this->vocabulary = $this->createVocabulary();
 
     // Setup a field and instance.
-    $this->field_name = drupal_strtolower($this->randomName());
+    $this->field_name = drupal_strtolower($this->randomSafeString());
     $this->field = array(
       'field_name' => $this->field_name,
       'type' => 'taxonomy_term_reference',
@@ -149,7 +149,7 @@ class TermFieldTest extends TaxonomyTestBase {
     );
     field_update_field($this->field);
     // Change the machine name.
-    $new_name = drupal_strtolower($this->randomName());
+    $new_name = drupal_strtolower($this->randomSafeString());
     $this->vocabulary->machine_name = $new_name;
     taxonomy_vocabulary_save($this->vocabulary);
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
index 31d01c5..dcf1b39 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermIndexTest.php
@@ -30,7 +30,7 @@ class TermIndexTest extends TaxonomyTestBase {
     // Create a vocabulary and add two term reference fields to article nodes.
     $this->vocabulary = $this->createVocabulary();
 
-    $this->field_name_1 = drupal_strtolower($this->randomName());
+    $this->field_name_1 = drupal_strtolower($this->randomSafeString());
     $this->field_1 = array(
       'field_name' => $this->field_name_1,
       'type' => 'taxonomy_term_reference',
@@ -60,7 +60,7 @@ class TermIndexTest extends TaxonomyTestBase {
     );
     field_create_instance($this->instance_1);
 
-    $this->field_name_2 = drupal_strtolower($this->randomName());
+    $this->field_name_2 = drupal_strtolower($this->randomSafeString());
     $this->field_2 = array(
       'field_name' => $this->field_name_2,
       'type' => 'taxonomy_term_reference',
@@ -102,8 +102,8 @@ class TermIndexTest extends TaxonomyTestBase {
     // Post an article.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
     $edit["{$this->field_name_1}[$langcode][]"] = $term_1->tid;
     $edit["{$this->field_name_2}[$langcode][]"] = $term_1->tid;
     $this->drupalPost('node/add/article', $edit, t('Save'));
@@ -149,7 +149,7 @@ class TermIndexTest extends TaxonomyTestBase {
     $this->assertEqual(1, $index_count, 'Term 2 is indexed once.');
 
     // Redo the above tests without interface.
-    $node->title = $this->randomName();
+    $node->title = $this->randomSafeString();
     unset($node->{$this->field_name_1});
     unset($node->{$this->field_name_2});
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
index d36a35e..0304337 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
@@ -107,8 +107,8 @@ class TermTest extends TaxonomyTestBase {
     // Post an article.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
     $edit[$this->instance['field_name'] . '[' . $langcode . '][]'] = $term1->tid;
     $this->drupalPost('node/add/article', $edit, t('Save'));
 
@@ -140,16 +140,16 @@ class TermTest extends TaxonomyTestBase {
     $instance['widget'] = array('type' => 'taxonomy_autocomplete');
     field_update_instance($instance);
     $terms = array(
-      'term1' => $this->randomName(),
-      'term2' => $this->randomName(),
-      'term3' => $this->randomName() . ', ' . $this->randomName(),
-      'term4' => $this->randomName(),
+      'term1' => $this->randomSafeString(),
+      'term2' => $this->randomSafeString(),
+      'term3' => $this->randomSafeString() . ', ' . $this->randomSafeString(),
+      'term4' => $this->randomSafeString(),
     );
 
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
     // Insert the terms in a comma separated list. Vocabulary 1 is a
     // free-tagging field created by the default profile.
     $edit[$instance['field_name'] . "[$langcode]"] = drupal_implode_tags($terms);
@@ -210,8 +210,8 @@ class TermTest extends TaxonomyTestBase {
     $this->assertRaw('{"' . $term_objects['term4']->name . '":"' . $term_objects['term4']->name . '"}', format_string('Autocomplete returns term %term_name after typing the first 3 letters.', array('%term_name' => $term_objects['term4']->name)));
 
     // Test taxonomy autocomplete with a nonexistent field.
-    $field_name = $this->randomName();
-    $tag = $this->randomName();
+    $field_name = $this->randomSafeString();
+    $tag = $this->randomSafeString();
     $message = t("Taxonomy field @field_name not found.", array('@field_name' => $field_name));
     $this->assertFalse(field_info_field($field_name), format_string('Field %field_name does not exist.', array('%field_name' => $field_name)));
     $this->drupalGet('taxonomy/autocomplete/' . $field_name . '/' . $tag);
@@ -274,8 +274,8 @@ class TermTest extends TaxonomyTestBase {
    */
   function testTermInterface() {
     $edit = array(
-      'name' => $this->randomName(12),
-      'description[value]' => $this->randomName(100),
+      'name' => $this->randomSafeString(12),
+      'description[value]' => $this->randomSafeString(100),
     );
     // Explicitly set the parents field to 'root', to ensure that
     // taxonomy_form_term_submit() handles the invalid term ID correctly.
@@ -300,8 +300,8 @@ class TermTest extends TaxonomyTestBase {
     $this->assertText($edit['description[value]'], 'The randomly generated term description is present.');
 
     $edit = array(
-      'name' => $this->randomName(14),
-      'description[value]' => $this->randomName(102),
+      'name' => $this->randomSafeString(14),
+      'description[value]' => $this->randomSafeString(102),
     );
 
     // Edit the term.
@@ -330,7 +330,7 @@ class TermTest extends TaxonomyTestBase {
 
     // Check that the term edit page does not try to interpret additional path
     // components as arguments for taxonomy_form_term().
-    $this->drupalGet('taxonomy/term/' . $term->tid . '/edit/' . $this->randomName());
+    $this->drupalGet('taxonomy/term/' . $term->tid . '/edit/' . $this->randomSafeString());
 
     // Delete the term.
     $this->drupalPost('taxonomy/term/' . $term->tid . '/edit', array(), t('Delete'));
@@ -409,8 +409,8 @@ class TermTest extends TaxonomyTestBase {
 
     // Add a new term with multiple parents.
     $edit = array(
-      'name' => $this->randomName(12),
-      'description[value]' => $this->randomName(100),
+      'name' => $this->randomSafeString(12),
+      'description[value]' => $this->randomSafeString(100),
       'parent[]' => array(0, $parent->tid),
     );
     // Save the new term.
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
index d63f176..dabb5d9 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php
@@ -37,9 +37,9 @@ class VocabularyTest extends TaxonomyTestBase {
     // Create a new vocabulary.
     $this->clickLink(t('Add vocabulary'));
     $edit = array();
-    $machine_name = drupal_strtolower($this->randomName());
-    $edit['name'] = $this->randomName();
-    $edit['description'] = $this->randomName();
+    $machine_name = drupal_strtolower($this->randomSafeString());
+    $edit['name'] = $this->randomSafeString();
+    $edit['description'] = $this->randomSafeString();
     $edit['machine_name'] = $machine_name;
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->assertRaw(t('Created new vocabulary %name.', array('%name' => $edit['name'])), 'Vocabulary created successfully.');
@@ -49,7 +49,7 @@ class VocabularyTest extends TaxonomyTestBase {
     $this->assertText($edit['name'], 'Vocabulary found in the vocabulary overview listing.');
     $this->clickLink(t('edit vocabulary'));
     $edit = array();
-    $edit['name'] = $this->randomName();
+    $edit['name'] = $this->randomSafeString();
     $this->drupalPost(NULL, $edit, t('Save'));
     $this->drupalGet('admin/structure/taxonomy');
     $this->assertText($edit['name'], 'Vocabulary found in the vocabulary overview listing.');
@@ -115,8 +115,8 @@ class VocabularyTest extends TaxonomyTestBase {
   function testTaxonomyAdminDeletingVocabulary() {
     // Create a vocabulary.
     $edit = array(
-      'name' => $this->randomName(),
-      'machine_name' => drupal_strtolower($this->randomName()),
+      'name' => $this->randomSafeString(),
+      'machine_name' => drupal_strtolower($this->randomSafeString()),
     );
     $this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
     $this->assertText(t('Created new vocabulary'), 'New vocabulary was created.');
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
index 8d94383..dceb594 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php
@@ -92,8 +92,8 @@ class VocabularyUnitTest extends TaxonomyTestBase {
 
     // Change the name and description.
     $vocabulary = $original_vocabulary;
-    $vocabulary->name = $this->randomName();
-    $vocabulary->description = $this->randomName();
+    $vocabulary->name = $this->randomSafeString();
+    $vocabulary->description = $this->randomSafeString();
     taxonomy_vocabulary_save($vocabulary);
 
     // Load the vocabulary.
@@ -174,7 +174,7 @@ class VocabularyUnitTest extends TaxonomyTestBase {
 
     // Change the machine name.
     $old_name = $this->vocabulary->machine_name;
-    $new_name = drupal_strtolower($this->randomName());
+    $new_name = drupal_strtolower($this->randomSafeString());
     $this->vocabulary->machine_name = $new_name;
     taxonomy_vocabulary_save($this->vocabulary);
 
@@ -193,14 +193,14 @@ class VocabularyUnitTest extends TaxonomyTestBase {
   function testUninstallReinstall() {
     // Fields and field instances attached to taxonomy term bundles should be
     // removed when the module is uninstalled.
-    $this->field_name = drupal_strtolower($this->randomName() . '_field_name');
+    $this->field_name = drupal_strtolower($this->randomSafeString() . '_field_name');
     $this->field = array('field_name' => $this->field_name, 'type' => 'text', 'cardinality' => 4);
     $this->field = field_create_field($this->field);
     $this->instance = array(
       'field_name' => $this->field_name,
       'entity_type' => 'taxonomy_term',
       'bundle' => $this->vocabulary->machine_name,
-      'label' => $this->randomName() . '_label',
+      'label' => $this->randomSafeString() . '_label',
     );
     field_create_instance($this->instance);
 
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
index 2706d3b..22e5125 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php
@@ -56,11 +56,11 @@ class TrackerTest extends WebTestBase {
     $this->drupalLogin($this->user);
 
     $unpublished = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'status' => 0,
     ));
     $published = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'status' => 1,
     ));
 
@@ -82,28 +82,28 @@ class TrackerTest extends WebTestBase {
     $this->drupalLogin($this->user);
 
     $unpublished = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'uid' => $this->user->uid,
       'status' => 0,
     ));
     $my_published = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'uid' => $this->user->uid,
       'status' => 1,
     ));
     $other_published_no_comment = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'uid' => $this->other_user->uid,
       'status' => 1,
     ));
     $other_published_my_comment = $this->drupalCreateNode(array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
       'uid' => $this->other_user->uid,
       'status' => 1,
     ));
     $comment = array(
-      'subject' => $this->randomName(),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+      'subject' => $this->randomSafeString(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomSafeString(20),
     );
     $this->drupalPost('comment/reply/' . $other_published_my_comment->nid, $comment, t('Save'));
 
@@ -128,7 +128,7 @@ class TrackerTest extends WebTestBase {
     $this->drupalLogin($this->user);
 
     $edit = array(
-      'title' => $this->randomName(8),
+      'title' => $this->randomSafeString(8),
     );
 
     $node = $this->drupalCreateNode($edit);
@@ -157,13 +157,13 @@ class TrackerTest extends WebTestBase {
 
     $node = $this->drupalCreateNode(array(
       'comment' => 2,
-      'title' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomName(8)))),
+      'title' => array(LANGUAGE_NOT_SPECIFIED => array(array('value' => $this->randomSafeString(8)))),
     ));
 
     // Add a comment to the page.
     $comment = array(
-      'subject' => $this->randomName(),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+      'subject' => $this->randomSafeString(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomSafeString(20),
     );
     // The new comment is automatically viewed by the current user.
     $this->drupalPost('comment/reply/' . $node->nid, $comment, t('Save'));
@@ -175,8 +175,8 @@ class TrackerTest extends WebTestBase {
 
     // Add another comment as other_user.
     $comment = array(
-      'subject' => $this->randomName(),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+      'subject' => $this->randomSafeString(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomSafeString(20),
     );
     // If the comment is posted in the same second as the last one then Drupal
     // can't tell the difference, so we wait one second here.
@@ -200,7 +200,7 @@ class TrackerTest extends WebTestBase {
     for ($i = 1; $i <= 3; $i++) {
       $edits[$i] = array(
         'comment' => 2,
-        'title' => $this->randomName(),
+        'title' => $this->randomSafeString(),
       );
       $nodes[$i] = $this->drupalCreateNode($edits[$i]);
     }
@@ -208,8 +208,8 @@ class TrackerTest extends WebTestBase {
     // Add a comment to the last node as other user.
     $this->drupalLogin($this->other_user);
     $comment = array(
-      'subject' => $this->randomName(),
-      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomName(20),
+      'subject' => $this->randomSafeString(),
+      'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomSafeString(20),
     );
     $this->drupalPost('comment/reply/' . $nodes[3]->nid, $comment, t('Save'));
 
@@ -254,7 +254,7 @@ class TrackerTest extends WebTestBase {
 
     $node = $this->drupalCreateNode(array(
       'comment' => 2,
-      'title' => $this->randomName(),
+      'title' => $this->randomSafeString(),
     ));
 
     // Assert that the node is displayed.
diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
index 2c2a4d2..10eff94 100644
--- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
+++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
@@ -62,8 +62,8 @@ class TranslationTest extends WebTestBase {
    */
   function testContentTranslation() {
     // Create Basic page in English.
-    $node_title = $this->randomName();
-    $node_body =  $this->randomName();
+    $node_title = $this->randomSafeString();
+    $node_body =  $this->randomSafeString();
     $node = $this->createPage($node_title, $node_body, 'en');
     // Unpublish the original node to check that this has no impact on the
     // translation overview page, publish it again afterwards.
@@ -80,8 +80,8 @@ class TranslationTest extends WebTestBase {
     $this->assertLinkByHref($prefixes['es'] . '/node/add/' . $node->type, 0, t('The "add translation" link for %language points to the localized path of the target language.', array('%language' => $languages['es']->name)));
 
     // Submit translation in Spanish.
-    $node_translation_title = $this->randomName();
-    $node_translation_body = $this->randomName();
+    $node_translation_title = $this->randomSafeString();
+    $node_translation_body = $this->randomSafeString();
     $node_translation = $this->createTranslation($node, $node_translation_title, $node_translation_body, 'es');
 
     // Check that the "edit translation" and "view node" links use localized
@@ -99,14 +99,14 @@ class TranslationTest extends WebTestBase {
     // to return to the page then resubmitting the form without a refresh.
     $edit = array();
     $langcode = LANGUAGE_NOT_SPECIFIED;
-    $edit["title"] = $this->randomName();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
+    $edit["title"] = $this->randomSafeString();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
     $this->drupalPost('node/add/page', $edit, t('Save'), array('query' => array('translation' => $node->nid, 'language' => 'es')));
     $duplicate = $this->drupalGetNodeByTitle($edit["title"]);
     $this->assertEqual($duplicate->tnid, 0, t('The node does not have a tnid.'));
 
     // Update original and mark translation as outdated.
-    $node_body = $this->randomName();
+    $node_body = $this->randomSafeString();
     $node->body[LANGUAGE_NOT_SPECIFIED][0]['value'] = $node_body;
     $edit = array();
     $edit["body[$langcode][0][value]"] = $node_body;
@@ -120,7 +120,7 @@ class TranslationTest extends WebTestBase {
 
     // Update translation and mark as updated.
     $edit = array();
-    $edit["body[$langcode][0][value]"] = $this->randomName();
+    $edit["body[$langcode][0][value]"] = $this->randomSafeString();
     $edit['translation[status]'] = FALSE;
     $this->drupalPost('node/' . $node_translation->nid . '/edit', $edit, t('Save'));
     $this->assertRaw(t('Basic page %title has been updated.', array('%title' => $node_translation_title)), t('Translated node updated.'));
@@ -129,7 +129,7 @@ class TranslationTest extends WebTestBase {
     // disabled languages.
     $this->drupalGet('node/add/page');
     $this->assertFieldByXPath('//select[@name="langcode"]//option', LANGUAGE_NOT_SPECIFIED, t('Language neutral is available in language selection with disabled languages.'));
-    $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED);
+    $node2 = $this->createPage($this->randomSafeString(), $this->randomSafeString(), LANGUAGE_NOT_SPECIFIED);
     $this->assertRaw($node2->body[LANGUAGE_NOT_SPECIFIED][0]['value'], t('Language neutral content created with disabled languages available.'));
 
     // Leave just one language installed and check that the translation overview
@@ -146,8 +146,8 @@ class TranslationTest extends WebTestBase {
    */
   function testLanguageSwitchLinks() {
     // Create a Basic page in English and its translation in Spanish.
-    $node = $this->createPage($this->randomName(), $this->randomName(), 'en');
-    $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es');
+    $node = $this->createPage($this->randomSafeString(), $this->randomSafeString(), 'en');
+    $translation_es = $this->createTranslation($node, $this->randomSafeString(), $this->randomSafeString(), 'es');
 
     // Check that language switch links are correctly shown for languages
     // we have translations for.
@@ -191,26 +191,26 @@ class TranslationTest extends WebTestBase {
 
     // Create a Basic page in English.
     $type = 'block-language';
-    $node = $this->createPage($this->randomName(), $this->randomName(), 'en');
+    $node = $this->createPage($this->randomSafeString(), $this->randomSafeString(), 'en');
     $this->assertLanguageSwitchLinks($node, $node, TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $this->emptyNode('es'), TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $this->emptyNode('it'), TRUE, $type);
 
     // Create the Spanish translation.
-    $translation_es = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'es');
+    $translation_es = $this->createTranslation($node, $this->randomSafeString(), $this->randomSafeString(), 'es');
     $this->assertLanguageSwitchLinks($node, $node, TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $this->emptyNode('it'), TRUE, $type);
 
     // Create the Italian translation.
-    $translation_it = $this->createTranslation($node, $this->randomName(), $this->randomName(), 'it');
+    $translation_it = $this->createTranslation($node, $this->randomSafeString(), $this->randomSafeString(), 'it');
     $this->assertLanguageSwitchLinks($node, $node, TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $translation_es, TRUE, $type);
     $this->assertLanguageSwitchLinks($node, $translation_it, TRUE, $type);
 
     // Create a language neutral node and check that the language switcher is
     // left untouched.
-    $node2 = $this->createPage($this->randomName(), $this->randomName(), LANGUAGE_NOT_SPECIFIED);
+    $node2 = $this->createPage($this->randomSafeString(), $this->randomSafeString(), LANGUAGE_NOT_SPECIFIED);
     $node2_en = (object) array('nid' => $node2->nid, 'langcode' => 'en');
     $node2_es = (object) array('nid' => $node2->nid, 'langcode' => 'es');
     $node2_it = (object) array('nid' => $node2->nid, 'langcode' => 'it');
@@ -233,7 +233,7 @@ class TranslationTest extends WebTestBase {
 
     // Check that new nodes with a language assigned do not trigger language
     // switcher alterations when translation support is disabled.
-    $node = $this->createPage($this->randomName(), $this->randomName());
+    $node = $this->createPage($this->randomSafeString(), $this->randomSafeString());
     $node_es = (object) array('nid' => $node->nid, 'langcode' => 'es');
     $node_it = (object) array('nid' => $node->nid, 'langcode' => 'it');
     $this->assertLanguageSwitchLinks($node, $node, TRUE, $type);
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
index 4e6a0d5..4bdb3b9 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php
@@ -287,8 +287,8 @@ class UserCancelTest extends WebTestBase {
     // Create comment.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array();
-    $edit['subject'] = $this->randomName(8);
-    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
+    $edit['subject'] = $this->randomSafeString(8);
+    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomSafeString(16);
 
     $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
     $this->drupalPost(NULL, array(), t('Save'));
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
index cfa7254..2747230 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
@@ -32,9 +32,9 @@ class UserCreateTest extends WebTestBase {
 
     foreach (array(FALSE, TRUE) as $notify) {
       $edit = array(
-        'name' => $this->randomName(),
-        'mail' => $this->randomName() . '@example.com',
-        'pass[pass1]' => $pass = $this->randomString(),
+        'name' => $this->randomSafeString(),
+        'mail' => $this->randomSafeString() . '@example.com',
+        'pass[pass1]' => $pass = $this->randomUnsafeString(),
         'pass[pass2]' => $pass,
         'notify' => $notify,
       );
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
index 6bf60bc..baff6e4 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEditTest.php
@@ -45,11 +45,11 @@ class UserEditTest extends WebTestBase {
     // Check that filling out a single password field does not validate.
     $edit = array();
     $edit['pass[pass1]'] = '';
-    $edit['pass[pass2]'] = $this->randomName();
+    $edit['pass[pass2]'] = $this->randomSafeString();
     $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
     $this->assertText(t("The specified passwords do not match."), t('Typing mismatched passwords displays an error message.'));
 
-    $edit['pass[pass1]'] = $this->randomName();
+    $edit['pass[pass1]'] = $this->randomSafeString();
     $edit['pass[pass2]'] = '';
     $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
     $this->assertText(t("The specified passwords do not match."), t('Typing mismatched passwords displays an error message.'));
@@ -57,7 +57,7 @@ class UserEditTest extends WebTestBase {
     // Test that the error message appears when attempting to change the mail or
     // pass without the current password.
     $edit = array();
-    $edit['mail'] = $this->randomName() . '@new.example.com';
+    $edit['mail'] = $this->randomSafeString() . '@new.example.com';
     $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
     $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('E-mail address'))));
 
@@ -67,7 +67,7 @@ class UserEditTest extends WebTestBase {
 
     // Test that the user must enter current password before changing passwords.
     $edit = array();
-    $edit['pass[pass1]'] = $new_pass = $this->randomName();
+    $edit['pass[pass1]'] = $new_pass = $this->randomSafeString();
     $edit['pass[pass2]'] = $new_pass;
     $this->drupalPost("user/$user1->uid/edit", $edit, t('Save'));
     $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => t('Password'))));
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
index d7d3bb2..a01e902 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEditedOwnAccountTest.php
@@ -33,7 +33,7 @@ class UserEditedOwnAccountTest extends WebTestBase {
 
     // Change own username.
     $edit = array();
-    $edit['name'] = $this->randomName();
+    $edit['name'] = $this->randomSafeString();
     $this->drupalPost('user/' . $account->uid . '/edit', $edit, t('Save'));
 
     // Log out.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
index dc85ade..4e213ea 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityCallbacksTest.php
@@ -35,7 +35,7 @@ class UserEntityCallbacksTest extends WebTestBase {
     $this->assertEqual($this->account->label(), $this->account->name, t('The username should be used as label'));
 
     // Setup a random anonymous name to be sure the name is used.
-    $name = $this->randomName();
+    $name = $this->randomSafeString();
     variable_set('anonymous', $name);
     $this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0'));
   }
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
index dce7d0b..0d3977e 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageCreationTest.php
@@ -58,10 +58,10 @@ class UserLanguageCreationTest extends WebTestBase {
 
     // Create a user with the admin/people/create form and check if the correct
     // language is set.
-    $username = $this->randomName(10);
+    $username = $this->randomSafeString(10);
     $edit = array(
       'name' => $username,
-      'mail' => $this->randomName(4) . '@example.com',
+      'mail' => $this->randomSafeString(4) . '@example.com',
       'pass[pass1]' => $username,
       'pass[pass2]' => $username,
     );
@@ -78,10 +78,10 @@ class UserLanguageCreationTest extends WebTestBase {
     $this->drupalGet($langcode . '/user/register');
     $this->assertNoFieldByName('language[fr]', t('Language selector is not accessible.'));
 
-    $username = $this->randomName(10);
+    $username = $this->randomSafeString(10);
     $edit = array(
       'name' => $username,
-      'mail' => $this->randomName(4) . '@example.com',
+      'mail' => $this->randomSafeString(4) . '@example.com',
     );
 
     $this->drupalPost($langcode . '/user/register', $edit, t('Create new account'));
@@ -99,7 +99,7 @@ class UserLanguageCreationTest extends WebTestBase {
     $this->assertFieldChecked("edit-preferred-langcode-$langcode", t('Language selector is accessible and correct language is selected.'));
 
     // Set pass_raw so we can login the new user.
-    $user->pass_raw = $this->randomName(10);
+    $user->pass_raw = $this->randomSafeString(10);
     $edit = array(
       'pass[pass1]' => $user->pass_raw,
       'pass[pass2]' => $user->pass_raw,
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php b/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
index 41084c3..2d08eab 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserLanguageTest.php
@@ -41,7 +41,7 @@ class UserLanguageTest extends WebTestBase {
     // Code for the language.
     $langcode = 'xx';
     // The English name for the language.
-    $name = $this->randomName(16);
+    $name = $this->randomSafeString(16);
     $edit = array(
       'predefined_langcode' => 'custom',
       'langcode' => $langcode,
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
index e57cc42..77f351b 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php
@@ -310,7 +310,7 @@ class UserPictureTest extends WebTestBase {
 
     // The form does not save with an invalid file size.
     $edit = array(
-      'user_picture_file_size' => $this->randomName(),
+      'user_picture_file_size' => $this->randomSafeString(),
     );
     $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration'));
     $this->assertNoText(t('The configuration options have been saved.'), 'The form does not save with an invalid file size.');
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
index 56ad9a0..58eb66d 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php
@@ -34,7 +34,7 @@ class UserRegistrationTest extends WebTestBase {
     // Allow registration by site visitors without administrator approval.
     variable_set('user_register', USER_REGISTER_VISITORS);
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
     $this->drupalPost('user/register', $edit, t('Create new account'));
     $this->assertText(t('A welcome message with further instructions has been sent to your e-mail address.'), t('User registered successfully.'));
@@ -45,7 +45,7 @@ class UserRegistrationTest extends WebTestBase {
     // Allow registration by site visitors, but require administrator approval.
     variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
     $this->drupalPost('user/register', $edit, t('Create new account'));
     $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail));
@@ -60,7 +60,7 @@ class UserRegistrationTest extends WebTestBase {
     // Allow registration by site visitors without administrator approval.
     variable_set('user_register', USER_REGISTER_VISITORS);
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
 
     // Try entering a mismatching password.
@@ -70,7 +70,7 @@ class UserRegistrationTest extends WebTestBase {
     $this->assertText(t('The specified passwords do not match.'), t('Typing mismatched passwords displays an error message.'));
 
     // Enter a correct password.
-    $edit['pass[pass1]'] = $new_pass = $this->randomName();
+    $edit['pass[pass1]'] = $new_pass = $this->randomSafeString();
     $edit['pass[pass2]'] = $new_pass;
     $this->drupalPost('user/register', $edit, t('Create new account'));
     $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail));
@@ -81,9 +81,9 @@ class UserRegistrationTest extends WebTestBase {
     // Allow registration by site visitors, but require administrator approval.
     variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
-    $edit['pass[pass1]'] = $pass = $this->randomName();
+    $edit['pass[pass1]'] = $pass = $this->randomSafeString();
     $edit['pass[pass2]'] = $pass;
     $this->drupalPost('user/register', $edit, t('Create new account'));
     $this->assertText(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.'), t('Users are notified of pending approval'));
@@ -123,7 +123,7 @@ class UserRegistrationTest extends WebTestBase {
     $duplicate_user = $this->drupalCreateUser();
 
     $edit = array();
-    $edit['name'] = $this->randomName();
+    $edit['name'] = $this->randomSafeString();
     $edit['mail'] = $duplicate_user->mail;
 
     // Attempt to create a new account using an existing e-mail address.
@@ -154,9 +154,9 @@ class UserRegistrationTest extends WebTestBase {
     $this->assertNoRaw('<fieldset id="edit-account"><legend>Account information</legend>', t('Account settings fieldset was hidden.'));
 
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
-    $edit['pass[pass1]'] = $new_pass = $this->randomName();
+    $edit['pass[pass1]'] = $new_pass = $this->randomSafeString();
     $edit['pass[pass2]'] = $new_pass;
     $this->drupalPost(NULL, $edit, t('Create new account'));
 
@@ -209,7 +209,7 @@ class UserRegistrationTest extends WebTestBase {
 
     // Check that validation errors are correctly reported.
     $edit = array();
-    $edit['name'] = $name = $this->randomName();
+    $edit['name'] = $name = $this->randomSafeString();
     $edit['mail'] = $mail = $edit['name'] . '@example.com';
     // Missing input in required field.
     $edit['test_user_field[und][0][value]'] = '';
@@ -249,7 +249,7 @@ class UserRegistrationTest extends WebTestBase {
       // Submit with three values.
       $edit['test_user_field[und][1][value]'] = $value + 1;
       $edit['test_user_field[und][2][value]'] = $value + 2;
-      $edit['name'] = $name = $this->randomName();
+      $edit['name'] = $name = $this->randomSafeString();
       $edit['mail'] = $mail = $edit['name'] . '@example.com';
       $this->drupalPost(NULL, $edit, t('Create new account'));
       // Check user fields.
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
index eaabdd2..4388141 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
@@ -58,9 +58,9 @@ class UserRolesAssignmentTest extends WebTestBase {
     $rid = $this->drupalCreateRole(array('administer content types'));
     // Create a new user and add the role at the same time.
     $edit = array(
-      'name' => $this->randomName(),
-      'mail' => $this->randomName() . '@example.com',
-      'pass[pass1]' => $pass = $this->randomString(),
+      'name' => $this->randomSafeString(),
+      'mail' => $this->randomSafeString() . '@example.com',
+      'pass[pass1]' => $pass = $this->randomUnsafeString(),
       'pass[pass2]' => $pass,
       "roles[$rid]" => $rid,
     );
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSaveTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSaveTest.php
index 655651f..882bd1e 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserSaveTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserSaveTest.php
@@ -29,7 +29,7 @@ class UserSaveTest extends WebTestBase {
     // User ID must be a number that is not in the database.
     $max_uid = db_query('SELECT MAX(uid) FROM {users}')->fetchField();
     $test_uid = $max_uid + mt_rand(1000, 1000000);
-    $test_name = $this->randomName();
+    $test_name = $this->randomSafeString();
 
     // Create the base user, based on drupalCreateUser().
     $user = entity_create('user', array(
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
index 19aa8c9..8b0902d 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php
@@ -76,7 +76,7 @@ class UserSignatureTest extends WebTestBase {
 
     // Log in as a regular user and create a signature.
     $this->drupalLogin($this->web_user);
-    $signature_text = "<h1>" . $this->randomName() . "</h1>";
+    $signature_text = "<h1>" . $this->randomSafeString() . "</h1>";
     $edit = array(
       'signature[value]' => $signature_text,
       'signature[format]' => $this->plain_text_format->format,
@@ -90,8 +90,8 @@ class UserSignatureTest extends WebTestBase {
     // Create a comment.
     $langcode = LANGUAGE_NOT_SPECIFIED;
     $edit = array();
-    $edit['subject'] = $this->randomName(8);
-    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomName(16);
+    $edit['subject'] = $this->randomSafeString(8);
+    $edit['comment_body[' . $langcode . '][0][value]'] = $this->randomSafeString(16);
     $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Preview'));
     $this->drupalPost(NULL, array(), t('Save'));
 
diff --git a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcValidatorTest.php b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcValidatorTest.php
index f482328..9d6edfd 100644
--- a/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcValidatorTest.php
+++ b/core/modules/xmlrpc/lib/Drupal/xmlrpc/Tests/XmlRpcValidatorTest.php
@@ -65,10 +65,10 @@ class XmlRpcValidatorTest extends WebTestBase {
 
     $int_5     = mt_rand(-100, 100);
     $bool_5    = (($int_5 % 2) == 0);
-    $string_5  = $this->randomName();
+    $string_5  = $this->randomSafeString();
     $double_5  = (double)(mt_rand(-1000, 1000) / 100);
     $time_5    = REQUEST_TIME;
-    $base64_5  = $this->randomName(100);
+    $base64_5  = $this->randomSafeString(100);
     $l_res_5 = xmlrpc_test_manyTypesTest($int_5, $bool_5, $string_5, $double_5, xmlrpc_date($time_5), $base64_5);
     // See http://drupal.org/node/37766 why this currently fails
     $l_res_5[5] = $l_res_5[5]->data;
@@ -79,7 +79,7 @@ class XmlRpcValidatorTest extends WebTestBase {
     $size = mt_rand(100, 200);
     $array_6 = array();
     for ($i = 0; $i < $size; $i++) {
-      $array_6[] = $this->randomName(mt_rand(8, 12));
+      $array_6[] = $this->randomSafeString(mt_rand(8, 12));
     }
 
     $l_res_6 = xmlrpc_test_moderateSizeArrayCheck($array_6);
