mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
prevent possible XSS attack via form helper selects and unescaped output.
This commit is contained in:
parent
aae0f762dd
commit
587a04ab84
2 changed files with 31 additions and 0 deletions
|
@ -4634,6 +4634,34 @@ class FormHelperTest extends CakeTestCase {
|
|||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
|
||||
$result = $this->Form->select(
|
||||
'Model.multi_field',
|
||||
array('a>b' => 'first', 'a<b' => 'second', 'a"b' => 'third'),
|
||||
array('multiple' => true)
|
||||
);
|
||||
$expected = array(
|
||||
'input' => array(
|
||||
'type' => 'hidden', 'name' => 'data[Model][multi_field]', 'value' => '',
|
||||
'id' => 'ModelMultiField_'
|
||||
),
|
||||
array('select' => array('name' => 'data[Model][multi_field][]',
|
||||
'multiple' => 'multiple', 'id' => 'ModelMultiField'
|
||||
)),
|
||||
array('option' => array('value' => 'a>b')),
|
||||
'first',
|
||||
'/option',
|
||||
array('option' => array('value' => 'a<b')),
|
||||
'second',
|
||||
'/option',
|
||||
array('option' => array(
|
||||
'value' => 'a"b'
|
||||
)),
|
||||
'third',
|
||||
'/option',
|
||||
'/select'
|
||||
);
|
||||
$this->assertTags($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2733,6 +2733,9 @@ class FormHelper extends AppHelper {
|
|||
$item = $this->Html->useTag('checkboxmultiple', $name, $htmlOptions);
|
||||
$select[] = $this->Html->div($attributes['class'], $item . $label);
|
||||
} else {
|
||||
if ($attributes['escape']) {
|
||||
$name = h($name);
|
||||
}
|
||||
$select[] = $this->Html->useTag('selectoption', $name, $htmlOptions, $title);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue