summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-30 22:52:24 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-30 22:52:24 +0000
commit75a7c31c337127dea4c64d77508d921a7a52889f (patch)
treed8a3d0343e31014922a8472b58ea35707863ed6f
parent540ce2b461ee6cef5ff0c7b6dd9d768b1338c229 (diff)
downloadbrdo-75a7c31c337127dea4c64d77508d921a7a52889f.tar.gz
brdo-75a7c31c337127dea4c64d77508d921a7a52889f.tar.bz2
#971120 by bec, dereine, bojanz, chx: Fixed Radio button values get run through check_plain() twice
-rw-r--r--includes/form.inc9
-rw-r--r--modules/simpletest/tests/form.test4
-rw-r--r--modules/simpletest/tests/form_test.module6
3 files changed, 13 insertions, 6 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 9018931ef..4f907dd8f 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -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'],
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test
index b2b822361..a73ac16c2 100644
--- a/modules/simpletest/tests/form.test
+++ b/modules/simpletest/tests/form.test
@@ -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);
diff --git a/modules/simpletest/tests/form_test.module b/modules/simpletest/tests/form_test.module
index fadd2aa9a..f908c212f 100644
--- a/modules/simpletest/tests/form_test.module
+++ b/modules/simpletest/tests/form_test.module
@@ -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) {