cvs diff: Diffing handlers
Index: handlers/views_handler_filter_in_operator.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/handlers/views_handler_filter_in_operator.inc,v
retrieving revision 1.11
diff -u -p -r1.11 views_handler_filter_in_operator.inc
--- handlers/views_handler_filter_in_operator.inc	1 Jul 2009 22:30:40 -0000	1.11
+++ handlers/views_handler_filter_in_operator.inc	23 Sep 2009 15:43:08 -0000
@@ -173,11 +173,6 @@ class views_handler_filter_in_operator e
     }
 
     if ($which == 'all' || $which == 'value') {
-      if ($this->value_form_type == 'checkboxes') {
-        foreach ($options as $key => $option) {
-          $options[$key] = check_plain($option);
-        }
-      }
       $form['value'] = array(
         '#type' => $this->value_form_type,
         '#title' => $this->value_title,
@@ -191,8 +186,17 @@ class views_handler_filter_in_operator e
         $form_state['input'][$identifier] = $default_value;
       }
 
+      $process = array();
+      if ($this->value_form_type == 'checkboxes') {
+        // If this form element will use checkboxes in the UI, we need to
+        // check_plain() all the options ourselves since FAPI is inconsistent
+        // about this. However, instead of directly doing that to the #options
+        // right now, we define a #process callback since we might change our
+        // mind later and convert this into a 'select' form element, which
+        // would lead to double-escaping the options.
+        $process[] = 'views_process_check_options';
+      }
       if ($which == 'all') {
-        $process = array();
         if (empty($form_state['exposed']) && ($this->value_form_type == 'checkboxes' || $this->value_form_type == 'radios')) {
           $process[] = "expand_$this->value_form_type";
           $form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
@@ -200,10 +204,14 @@ class views_handler_filter_in_operator e
         }
         $process[] = 'views_process_dependency';
         $form['value'] += array(
-          '#process' => $process,
           '#dependency' => array($source => $this->operator_values(1)),
         );
       }
+      if (!empty($process)) {
+        $form['value'] += array(
+          '#process' => $process,
+        );
+      }
     }
   }
 
cvs diff: Diffing includes
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/form.inc,v
retrieving revision 1.10
diff -u -p -r1.10 form.inc
--- includes/form.inc	25 Jun 2008 21:10:10 -0000	1.10
+++ includes/form.inc	23 Sep 2009 15:43:08 -0000
@@ -280,3 +280,20 @@ function views_process_dependency($eleme
 
   return $element;
 }
+
+/**
+ * #process callback to see if we need to check_plain() the options.
+ *
+ * Since FAPI is inconsistent, the #options are sanitized for you in all cases
+ * _except_ checkboxes. We have form elements that are sometimes 'select' and
+ * sometimes 'checkboxes', so we need decide late in the form rendering cycle
+ * if the options need to be sanitized before they're rendered. This callback
+ * inspects the type, and if it's still 'checkboxes', does the sanitation.
+ */
+function views_process_check_options($element, $edit, &$form_state, &$form) {
+  if ($element['#type'] == 'checkboxes' || $element['#type'] == 'checkbox') {
+    $element['#options'] = array_map('check_plain', $element['#options']);
+  }
+  return $element;
+}
+
