diff --git a/core/modules/simpletest/src/TestBase.php b/core/modules/simpletest/src/TestBase.php
index 4104b4b..e2f0d58 100644
--- a/core/modules/simpletest/src/TestBase.php
+++ b/core/modules/simpletest/src/TestBase.php
@@ -1468,15 +1468,9 @@ public function randomStringValidate($string) {
       return FALSE;
     }
 
-    // Starting with a space means that length might not be what is expected.
-    // Starting with an @ sign causes CURL to fail if used in conjunction with a
-    // file upload. See https://www.drupal.org/node/2174997.
-    if (preg_match('/^(\s|@)/', $string)) {
-      return FALSE;
-    }
-
-    // Ending with a space means that length might not be what is expected.
-    if (preg_match('/\s$/', $string)) {
+    // Starting or ending with a space means that length might not be what is
+    // expected.
+    if (preg_match('/^(\s.*)|(.*\s)$/', $string)) {
       return FALSE;
     }
 
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 2ac0d4b..4d30e26 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1248,6 +1248,8 @@ protected function curlInitialize() {
         CURLOPT_SSL_VERIFYHOST => FALSE,
         CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'),
         CURLOPT_USERAGENT => $this->databasePrefix,
+        // Disable support for the @ prefix for uploading files.
+        CURLOPT_SAFE_UPLOAD => TRUE,
       );
       if (isset($this->httpAuthCredentials)) {
         $curl_options[CURLOPT_HTTPAUTH] = $this->httpAuthMethod;
@@ -1601,9 +1603,6 @@ protected function drupalGetAjax($path, array $options = array(), array $headers
    *   $edit = array();
    *   $edit['name[]'] = array('value1', 'value2');
    *   @endcode
-   *
-   *   Note that when a form contains file upload fields, other
-   *   fields cannot start with the '@' character.
    * @param $submit
    *   Value of the submit button whose click is to be emulated. For example,
    *   t('Save'). The processing of the request depends on this value. For
diff --git a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
index f4a005f..1b2cb6b 100644
--- a/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Unit/TestBaseTest.php
@@ -73,7 +73,7 @@ public function providerRandomStringValidate() {
       array(FALSE, 'curry   paste'),
       array(TRUE, 'curry paste'),
       array(TRUE, 'thai green curry paste'),
-      array(FALSE, '@startswithat'),
+      array(TRUE, '@startswithat'),
       array(TRUE, 'contains@at'),
     );
   }
