### Eclipse Workspace Patch 1.0
#P Drupal-7-Dev
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.638
diff -u -r1.638 system.module
--- modules/system/system.module	15 Nov 2008 08:23:07 -0000	1.638
+++ modules/system/system.module	16 Nov 2008 01:34:47 -0000
@@ -308,6 +308,7 @@
   $type['file'] = array(
     '#input' => TRUE,
     '#size' => 60,
+    '#enctype' => 'multipart/form-data',
   );
 
 
Index: modules/system/system.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v
retrieving revision 1.104
diff -u -r1.104 system.admin.inc
--- modules/system/system.admin.inc	11 Nov 2008 22:39:59 -0000	1.104
+++ modules/system/system.admin.inc	16 Nov 2008 01:34:42 -0000
@@ -517,7 +517,6 @@
       }
     }
   }
-  $form['#attributes'] = array('enctype' => 'multipart/form-data');
 
   $form = system_settings_form($form);
   // We don't want to call system_settings_form_submit(), so change #submit.
Index: modules/user/user.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v
retrieving revision 1.22
diff -u -r1.22 user.pages.inc
--- modules/user/user.pages.inc	13 Oct 2008 00:33:05 -0000	1.22
+++ modules/user/user.pages.inc	16 Nov 2008 01:34:49 -0000
@@ -246,7 +246,6 @@
       '#submit' => array('user_edit_delete_submit'),
     );
   }
-  $form['#attributes']['enctype'] = 'multipart/form-data';
 
   return $form;
 }
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.304
diff -u -r1.304 form.inc
--- includes/form.inc	15 Nov 2008 15:32:36 -0000	1.304
+++ includes/form.inc	16 Nov 2008 01:34:36 -0000
@@ -852,7 +852,7 @@
  *   $_POST data.
  */
 function form_builder($form_id, $form, &$form_state) {
-  static $complete_form, $cache, $file;
+  static $complete_form, $cache, $enctype;
 
   // Initialize as unprocessed.
   $form['#processed'] = FALSE;
@@ -865,6 +865,7 @@
 
   if (isset($form['#type']) && $form['#type'] == 'form') {
     $cache = NULL;
+    $enctype = NULL;
     $complete_form = $form;
     if (!empty($form['#programmed'])) {
       $form_state['submitted'] = TRUE;
@@ -943,19 +944,21 @@
   if (!empty($form['#cache'])) {
     $cache = $form['#cache'];
   }
-  // If there is a file element, we need to flip a static flag so later the
-  // form encoding can be set.
-  if (isset($form['#type']) && $form['#type'] == 'file') {
-    $file = TRUE;
+  // If an element requires to set the forms content type enctype attribute, we
+  // need to store this info in a static $enctype flag to update the parent
+  // form element. E.g. For files, non-ASCII data, and binary data.
+  if (isset($form['#enctype'])) {
+    $enctype = $form['#enctype'];
   }
+
   if (isset($form['#type']) && $form['#type'] == 'form') {
     // We are on the top form, we can copy back #cache if it's set.
     if (isset($cache)) {
       $form['#cache'] = TRUE;
     }
-    // If there is a file element, we set the form encoding.
-    if (isset($file)) {
-      $form['#attributes']['enctype'] = 'multipart/form-data';
+    // Set the form encoding if required.
+    if (isset($enctype)) {
+      $form['#attributes']['enctype'] = $enctype;
     }
   }
   return $form;
Index: modules/upload/upload.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v
retrieving revision 1.215
diff -u -r1.215 upload.module
--- modules/upload/upload.module	8 Nov 2008 21:35:10 -0000	1.215
+++ modules/upload/upload.module	16 Nov 2008 01:34:48 -0000
@@ -258,7 +258,6 @@
       }
       else {
         $form['attachments']['wrapper'] += _upload_form($node);
-        $form['#attributes']['enctype'] = 'multipart/form-data';
       }
     }
     $form['#submit'][] = 'upload_node_form_submit';
