Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.413
diff -u -9 -p -r1.413 form.inc
--- includes/form.inc	2 Dec 2009 15:09:16 -0000	1.413
+++ includes/form.inc	2 Dec 2009 22:20:26 -0000
@@ -1801,22 +1801,22 @@ function form_get_options($element, $key
  *   A themed HTML string representing the group of items.
  *
  * @ingroup themeable
  */
 function theme_fieldset($variables) {
   $element = $variables['element'];
 
   $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
   if (!empty($element['#title'])) {
-    $output .= '<legend>' . $element['#title'] . '</legend>';
+    $output .= '<legend>' . filter_xss_admin($element['#title']) . '</legend>';
   }
   if (!empty($element['#description'])) {
-    $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
+    $output .= '<div class="fieldset-description">' . filter_xss_admin($element['#description']) . '</div>';
   }
   $output .= $element['#children'];
   if (isset($element['#value'])) {
     $output .= $element['#value'];
   }
   $output .= "</fieldset>\n";
   return $output;
 }
 
@@ -1834,20 +1834,22 @@ function theme_fieldset($variables) {
  *
  * @ingroup themeable
  */
 function theme_radio($variables) {
   $element = $variables['element'];
   _form_set_class($element, array('form-radio'));
   $output = '<input type="radio" ';
   $output .= 'id="' . $element['#id'] . '" ';
   $output .= 'name="' . $element['#name'] . '" ';
-  $output .= 'value="' . $element['#return_value'] . '" ';
-  $output .= (check_plain($element['#value']) == $element['#return_value']) ? ' checked="checked" ' : ' ';
+  $output .= 'value="' . check_plain($element['#return_value']) . '" ';
+  if ($element['#value'] == $element['#return_value']) {
+    $output .= 'checked="checked" ';
+  }
   $output .= drupal_attributes($element['#attributes']) . ' />';
 
   return $output;
 }
 
 /**
  * Theme a set of radio button form elements.
  *
  * @param $variables
@@ -2041,19 +2043,19 @@ function form_process_radios($element) {
   if (count($element['#options']) > 0) {
     foreach ($element['#options'] as $key => $choice) {
       if (!isset($element[$key])) {
         // Generate the parents as the autogenerator does, so we will have a
         // unique id for each radio button.
         $parents_for_id = array_merge($element['#parents'], array($key));
         $element[$key] = array(
           '#type' => 'radio',
           '#title' => $choice,
-          '#return_value' => check_plain($key),
+          '#return_value' => $key,
           '#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
           '#attributes' => $element['#attributes'],
           '#parents' => $element['#parents'],
           '#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
           '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
         );
       }
     }
   }
@@ -2150,19 +2152,19 @@ function form_process_text_format($eleme
  * @ingroup themeable
  */
 function theme_text_format_wrapper($variables) {
   $element = $variables['element'];
   $output = '<div class="text-format-wrapper">' . "\n";
 
   $output .= $element['#children'] . "\n";
 
   if (!empty($element['#description'])) {
-    $output .= '<div class="description">' . $element['#description'] . "</div>\n";
+    $output .= '<div class="description">' . filter_xss_admin($element['#description']) . "</div>\n";
   }
 
   $output .= "</div>\n";
 
   return $output;
 }
 
 /**
  * Theme a checkbox form element.
@@ -2180,19 +2182,19 @@ function theme_text_format_wrapper($vari
  */
 function theme_checkbox($variables) {
   $element = $variables['element'];
   $t = get_t();
   _form_set_class($element, array('form-checkbox'));
   $checkbox = '<input ';
   $checkbox .= 'type="checkbox" ';
   $checkbox .= 'name="' . $element['#name'] . '" ';
   $checkbox .= 'id="' . $element['#id'] . '" ' ;
-  $checkbox .= 'value="' . $element['#return_value'] . '" ';
+  $checkbox .= 'value="' . check_plain($element['#return_value']) . '" ';
   // Unchecked checkbox has #value of numeric 0.
   if ($element['#value'] !== 0 && $element['#value'] == $element['#return_value']) {
     $checkbox .= 'checked="checked" ';
   }
   $checkbox .= drupal_attributes($element['#attributes']) . ' />';
 
   return $checkbox;
 }
 
@@ -2250,18 +2252,19 @@ function form_process_checkboxes($elemen
       $element['#default_value'] = array();
     }
     foreach ($element['#options'] as $key => $choice) {
       if (!isset($element[$key])) {
         $element[$key] = array(
           '#type' => 'checkbox',
           '#processed' => TRUE,
           '#title' => $choice,
           '#return_value' => $key,
+          '#name' => $element['#name'] . '[' . check_plain($key) . ']',
           '#default_value' => isset($value[$key]) ? $key : NULL,
           '#attributes' => $element['#attributes'],
           '#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
         );
       }
     }
   }
   return $element;
 }
@@ -2898,19 +2901,19 @@ function theme_form_element($variables) 
 
     case 'none':
     case 'attribute':
       // Output no label and no required marker, only the children.
       $output .= ' ' . $element['#children'] . "\n";
       break;
   }
 
   if (!empty($element['#description'])) {
-    $output .= ' <div class="description">' . $element['#description'] . "</div>\n";
+    $output .= ' <div class="description">' . filter_xss_admin($element['#description']) . "</div>\n";
   }
 
   $output .= "</div>\n";
 
   return $output;
 }
 
 /**
  * Theme the marker for required form elements.
