Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.24
diff -u -p -r1.24 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	2 Jul 2008 20:05:11 -0000	1.24
+++ modules/simpletest/drupal_web_test_case.php	3 Jul 2008 18:32:21 -0000
@@ -820,7 +820,9 @@ class DrupalWebTestCase {
    * @param  $edit
    *   Field data in an assocative array. Changes the current input fields
    *   (where possible) to the values indicated. A checkbox can be set to
-   *   TRUE to be checked and FALSE to be unchecked.
+   *   TRUE to be checked and FALSE to be unchecked. Note that when a form
+   *   contains file upload fields, other fields cannot start with the '@'
+   *   character.
    * @param $submit
    *   Value of the submit button.
    * @param $options
@@ -846,10 +848,24 @@ class DrupalWebTestCase {
         // We post only if we managed to handle every field in edit and the
         // submit button matches.
         if (!$edit && $submit_matches) {
-          // cURL will handle file upload for us if asked kindly.
-          foreach ($upload as $key => $file) {
-            $post[$key] = '@' . realpath($file);
+          if ($upload) {
+            // TODO: cURL handles file uploads for us, but the implementation
+            // is broken.
+            // This is a less than elegant workaround. Alternatives are
+            // being explored at #253506.
+            foreach ($upload as $key => $file) {
+              $post[$key] = '@' . realpath($file);
+            }
           }
+          else {
+            foreach ($post as $key => $value) {
+              // Encode according to application/x-www-form-urlencoded
+              // Both names and values needs to be urlencoded, according to
+              // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
+              $post[$key] = urlencode($key) . '=' . urlencode($value);
+            }
+            $post = implode('&', $post);
+          }  
           $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post));
           // Ensure that any changes to variables in the other thread are picked up.
           $this->refreshVariables();
