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/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
index 2119fe0..544b835 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentContentRebuildTest.php
@@ -38,7 +38,7 @@ class CommentContentRebuildTest extends CommentTestBase {
     $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/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
index 6136133..d1400cf 100644
--- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php
@@ -183,7 +183,7 @@ class ContactSitewideTest extends WebTestBase {
     // 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));
+    $this->submitContact($this->randomName(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'));
@@ -192,7 +192,7 @@ class ContactSitewideTest extends WebTestBase {
 
     // 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));
+    $this->submitContact($this->randomName(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'));
@@ -201,7 +201,7 @@ class ContactSitewideTest extends WebTestBase {
 
     // 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));
+    $this->submitContact($this->randomName(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/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
index 99842e5..e6419df 100644
--- a/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
+++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php
@@ -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/TranslationTest.php b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
index ce76545..73efad7 100644
--- a/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
+++ b/core/modules/field/lib/Drupal/field/Tests/TranslationTest.php
@@ -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);
     }
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
index 28ca832..491c4e6 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
@@ -58,7 +58,7 @@ class MenuNodeTest extends WebTestBase {
     $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);
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/poll/lib/Drupal/poll/Tests/PollTestBase.php b/core/modules/poll/lib/Drupal/poll/Tests/PollTestBase.php
index a554dd9..f0a28fe 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.'));
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
index 902fe6a..55c1d9b 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));
@@ -805,6 +818,25 @@ abstract class TestBase {
   }
 
   /**
+   * Generates a random string containing letters and numbers.
+   *
+   * This is a wrapper for Drupal\simpletest\TestBase::randomSafeString().
+   *
+   * @param $length
+   *   Length of random string to generate.
+   *
+   * @return
+   *   Randomly generated string.
+   *
+   * @see Drupal\simpletest\TestBase::randomSafeString()
+   *
+   * @todo Remove this wrapper?
+   */
+  public static function randomName($length = 8) {
+    return $this->randomSafeString($length);
+  }
+
+  /**
    * Converts a list of possible parameters into a stack of permutations.
    *
    * Takes a list of parameters containing possible values, and converts all of
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/MailCaptureTest.php
index da0fb5d..985a34d 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),
+        'subject' => $this->randomUnsafeString(64),
         'to' => $this->randomName(32) . '@example.com',
-        'body' => $this->randomString(512),
+        '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..65e4a2b 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -417,7 +417,7 @@ abstract class WebTestBase extends TestBase {
     }
     // 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/system/lib/Drupal/system/Tests/Form/FormTest.php b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
index 20d1f56..bc18942 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Form/FormTest.php
@@ -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/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/user/lib/Drupal/user/Tests/UserCreateTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
index cfa7254..5a66eba 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserCreateTest.php
@@ -34,7 +34,7 @@ class UserCreateTest extends WebTestBase {
       $edit = array(
         'name' => $this->randomName(),
         'mail' => $this->randomName() . '@example.com',
-        'pass[pass1]' => $pass = $this->randomString(),
+        'pass[pass1]' => $pass = $this->randomUnsafeString(),
         'pass[pass2]' => $pass,
         'notify' => $notify,
       );
diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
index eaabdd2..2b79597 100644
--- a/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
+++ b/core/modules/user/lib/Drupal/user/Tests/UserRolesAssignmentTest.php
@@ -60,7 +60,7 @@ class UserRolesAssignmentTest extends WebTestBase {
     $edit = array(
       'name' => $this->randomName(),
       'mail' => $this->randomName() . '@example.com',
-      'pass[pass1]' => $pass = $this->randomString(),
+      'pass[pass1]' => $pass = $this->randomUnsafeString(),
       'pass[pass2]' => $pass,
       "roles[$rid]" => $rid,
     );
