Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.283
diff -u -p -r1.283 form.inc
--- includes/form.inc	17 Sep 2008 07:11:56 -0000	1.283
+++ includes/form.inc	17 Sep 2008 19:27:32 -0000
@@ -1041,7 +1041,11 @@ function _form_builder_handle_input_elem
     }
     $form['#processed'] = TRUE;
   }
-  form_set_value($form, $form['#value'], $form_state);
+  // If the #process callback did not set a #value then we do not want to run
+  // form_set_value. However, NULL is a valid value.
+  if (isset($form['#value']) || array_key_exists('#value', $form)) {
+    form_set_value($form, $form['#value'], $form_state);
+  }
 }
 
 /**
@@ -1742,6 +1746,33 @@ function form_process_radios($element) {
   return $element;
 }
 
+function form_process_input_format($element) {
+  if (isset($element['#input_format'])) {
+    $element_parents = $element['#parents'];
+    $format_parents = $element_parents;
+    $last_parent = array_pop($format_parents);
+    $format_parents[] = $last_parent .'_format';
+    // As the id of the body child would be the same as the current id, we need
+    // to flush that id.
+    form_clean_id(NULL, TRUE, $element['#id']);
+    $element = array(
+      '#type' => 'markup',
+      '#post' => $element['#post'],
+      '#programmed' => $element['#programmed'],
+      '#tree' => TRUE,
+      '#parents' => array(),
+      '#weight' => $element['#weight'],
+      '#sorted' => TRUE,
+      'value' => $element,
+      'format' => filter_form($element['#input_format'], 1, $format_parents),
+    );
+    unset($element['value']['#name'], $element['value']['#id'], $element['value']['#value'], $element['value']['#input_format']);
+    $element['value']['#weight'] = 0;
+    $element['value']['#parents'] = $element_parents;
+  }
+  return $element;
+}
+
 /**
  * Add AHAH information about a form element to the page to communicate with
  * javascript. If #ahah[path] is set on an element, this additional javascript is
@@ -1782,6 +1813,8 @@ function form_process_ahah($element) {
       case 'select':
         $element['#ahah']['event'] = 'change';
         break;
+      default:
+        return $element;
     }
   }
 
@@ -2229,14 +2262,22 @@ function _form_set_class(&$element, $cla
  *   used if a form has completed the validation process. This parameter
  *   should never be set to TRUE if this function is being called to
  *   assign an ID to the #ID element.
+ * @param $id_to_flush
+ *   When $flush is TRUE, this flushes one instance of this id from the static
+ *   cache.
  * @return
  *   The cleaned ID.
  */
-function form_clean_id($id = NULL, $flush = FALSE) {
+function form_clean_id($id = NULL, $flush = FALSE, $id_to_flush = '') {
   static $seen_ids = array();
 
   if ($flush) {
-    $seen_ids = array();
+    if (!$id_to_flush) {
+      $seen_ids = array();
+    }
+    elseif (!empty($seen_ids[$id_to_flush])) {
+      $seen_ids[$id_to_flush]--;
+    }
     return;
   }
   $id = str_replace(array('][', '_', ' '), '-', $id);
@@ -2247,7 +2288,7 @@ function form_clean_id($id = NULL, $flus
   // forms that appear more than once on the page, but the alternative is
   // outputting duplicate IDs, which would break JS code and XHTML
   // validity anyways. For now, it's an acceptable stopgap solution.
-  if (isset($seen_ids[$id])) {
+  if (!empty($seen_ids[$id])) {
     $id = $id . '-' . $seen_ids[$id]++;
   }
   else {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.976
diff -u -p -r1.976 node.module
--- modules/node/node.module	17 Sep 2008 07:11:57 -0000	1.976
+++ modules/node/node.module	17 Sep 2008 17:00:12 -0000
@@ -858,6 +858,7 @@ function node_submit($node) {
   // module-provided 'teaser' form item).
   if (!isset($node->teaser)) {
     if (isset($node->body)) {
+      $node->format = empty($node->body_format) ? FILTER_FORMAT_DEFAULT : $node->body_format;
       $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL);
       // Chop off the teaser from the body if needed. The teaser_include
       // property might not be set (eg. in Blog API postings), so only act on
@@ -938,7 +939,6 @@ function node_save(&$node) {
   $node->changed = REQUEST_TIME;
 
   $node->timestamp = REQUEST_TIME;
-  $node->format = isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT;
   $update_node = TRUE;
 
   // Generate the node table query and the node_revisions table query.
Index: modules/node/node.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v
retrieving revision 1.36
diff -u -p -r1.36 node.pages.inc
--- modules/node/node.pages.inc	17 Sep 2008 07:11:57 -0000	1.36
+++ modules/node/node.pages.inc	17 Sep 2008 17:00:12 -0000
@@ -295,10 +295,9 @@ function node_body_field(&$node, $label,
     '#default_value' => $include ? $node->body : ($node->teaser . $node->body),
     '#rows' => 20,
     '#required' => ($word_count > 0),
+    '#input_format' => isset($node->format) ? $node->format : FILTER_FORMAT_DEFAULT,
   );
 
-  $form['format'] = filter_form($node->format);
-
   return $form;
 }
 
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.621
diff -u -p -r1.621 system.module
--- modules/system/system.module	17 Sep 2008 07:11:58 -0000	1.621
+++ modules/system/system.module	17 Sep 2008 19:08:25 -0000
@@ -219,7 +219,7 @@ function system_elements() {
     '#size' => 60,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('form_process_ahah'),
+    '#process' => array('form_process_input_format', 'form_process_ahah'),
   );
 
   $type['password'] = array(
@@ -239,7 +239,7 @@ function system_elements() {
     '#cols' => 60,
     '#rows' => 5,
     '#resizable' => TRUE,
-    '#process' => array('form_process_ahah'),
+    '#process' => array('form_process_input_format', 'form_process_ahah'),
   );
 
   $type['radios'] = array(
