Commit 75a7c31c authored by webchick's avatar webchick

#971120 by bec, dereine, bojanz, chx: Fixed Radio button values get run through check_plain() twice

parent 540ce2b4
......@@ -2658,6 +2658,9 @@ function theme_fieldset($variables) {
/**
* Returns HTML for a radio button form element.
*
* Note: The input "name" attribute needs to be sanitized before output, which
* is currently done by passing all attributes to drupal_attributes().
*
* @param $variables
* An associative array containing:
* - element: An associative array containing the properties of the element.
......@@ -2671,7 +2674,7 @@ function theme_radio($variables) {
$element['#attributes']['type'] = 'radio';
element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
if (isset($element['#return_value']) && check_plain($element['#value']) == $element['#return_value']) {
if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
$element['#attributes']['checked'] = 'checked';
}
_form_set_class($element, array('form-radio'));
......@@ -2890,7 +2893,9 @@ function form_process_radios($element) {
$element[$key] += array(
'#type' => 'radio',
'#title' => $choice,
'#return_value' => check_plain($key),
// The key is sanitized in drupal_attributes() during output from the
// theme function.
'#return_value' => $key,
'#default_value' => isset($element['#default_value']) ? $element['#default_value'] : NULL,
'#attributes' => $element['#attributes'],
'#parents' => $element['#parents'],
......
......@@ -396,7 +396,7 @@ class FormElementTestCase extends DrupalWebTestCase {
// Verify that all options appear in their defined order.
foreach (array('checkbox', 'radio') as $type) {
$elements = $this->xpath('//input[@type=:type]', array(':type' => $type));
$expected_values = array('0', 'foo', '1', 'bar');
$expected_values = array('0', 'foo', '1', 'bar', '>');
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
......@@ -410,7 +410,7 @@ class FormElementTestCase extends DrupalWebTestCase {
// #weight into account.
foreach (array('checkbox', 'radio') as $type) {
$elements = $this->xpath('//input[@type=:type]', array(':type' => $type));
$expected_values = array('0', 'foo', 'bar', '1');
$expected_values = array('0', 'foo', 'bar', '>', '1');
foreach ($elements as $element) {
$expected = array_shift($expected_values);
$this->assertIdentical((string) $element['value'], $expected);
......
......@@ -355,7 +355,7 @@ function form_test_limit_validation_errors_form($form, &$form_state) {
'#type' => 'textfield',
'#element_validate' => array('form_test_limit_validation_errors_element_validate_test'),
);
$form['test_substring'] = array(
'#tree' => TRUE,
);
......@@ -369,7 +369,7 @@ function form_test_limit_validation_errors_form($form, &$form_state) {
'#type' => 'textfield',
'#element_validate' => array('form_test_limit_validation_errors_element_validate_test'),
);
$form['actions']['partial'] = array(
'#type' => 'submit',
'#limit_validation_errors' => array(array('test')),
......@@ -997,6 +997,7 @@ function form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) {
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
),
);
if ($customize) {
......@@ -1020,6 +1021,7 @@ function form_test_checkboxes_radios($form, &$form_state, $customize = FALSE) {
'foo' => 'Foo',
1 => 'One',
'bar' => 'Bar',
'>' => 'Special Char',
),
);
if ($customize) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment